generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Is this a Datastores glitch?

Previous Thread :: Next Thread 
devTools is online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
01 Jul 2015 10:14 AM
Okay so basically I am doing this datastore to make it so it is anti-AA. It is in my group's credit system and we don't want any HRs to AA and then leave or whatnot, so this is the script I have. It works the first time, but if I change it again, it makes their credits whatever I first changed it to.
Example:
>Has 5 credits
>I change it to 999,999
>Goes back to 5
>I change it to 5000
>Goes back to 999,999

Code:
game.Players.PlayerAdded:connect(function(player)
local rank = player:GetRankInGroup(129425)
spawn(function()
local credits = player:WaitForChild("leaderstats"):WaitForChild("Credits")
delay(1, function()
credits.Value = ds:GetAsync(player.userId .. '_Credits') or 0
credits.Changed:connect(function(value)
if rank < 5 then
if tonumber(credits.Value) > rank * 5 then
credits.Value = ds:GetAsync(player.userId .. '_Credits')
end
elseif rank >= 5 and rank < 10 then
if tonumber(credits.Value) > (20 + ((rank-4) * 8)) then
credits.Value = ds:GetAsync(player.userId .. '_Credits')
end
elseif rank > 10 then
ds:SetAsync(player.userId .. '_Credits', value)
end
wait(1)
ds:SetAsync(player.userId .. '_Credits', value)
end)
end)
end)
end)



| devTools || You can't flame a man on fire |
Report Abuse
devTools is online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
01 Jul 2015 10:16 AM
When it does :SetAsync, shouldn't the credit be fixed by then? That way it would save their OLD credits instead of the one they changed it to, right?

Then there's the question of if you changed the person's credits before 1 second is over (The wait time)...



| devTools || You can't flame a man on fire |
Report Abuse
devTools is online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
01 Jul 2015 10:19 AM
bump



| devTools || You can't flame a man on fire |
Report Abuse
StartDeveloping is not online. StartDeveloping
Joined: 16 Feb 2015
Total Posts: 740
01 Jul 2015 10:22 AM
Try adding credits.Changed:connect(function(value) so whenever it changes the value, it saves.
Report Abuse
StartDeveloping is not online. StartDeveloping
Joined: 16 Feb 2015
Total Posts: 740
01 Jul 2015 10:23 AM
Can u show the the ds variable, i'm fixing it 4 u scrub
Report Abuse
devTools is online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
01 Jul 2015 10:23 AM
ds = game:GetService("DataStoreService"):GetGlobalDataStore()

game.Players.PlayerAdded:connect(function(player)
local rank = player:GetRankInGroup(129425)
spawn(function()
local credits = player:WaitForChild("leaderstats"):WaitForChild("Credits")
delay(1, function()
credits.Value = ds:GetAsync(player.userId .. '_Credits') or 0
credits.Changed:connect(function(value)
if rank < 5 then
if tonumber(credits.Value) > rank * 5 then
credits.Value = ds:GetAsync(player.userId .. '_Credits')
end
elseif rank >= 5 and rank < 10 then
if tonumber(credits.Value) > (20 + ((rank-4) * 8)) then
credits.Value = ds:GetAsync(player.userId .. '_Credits')
end
elseif rank > 10 then
ds:SetAsync(player.userId .. '_Credits', value)
end
wait(1)
ds:SetAsync(player.userId .. '_Credits', value)
end)
end)
end)
end)

Thanks!



| devTools || You can't flame a man on fire |
Report Abuse
StartDeveloping is not online. StartDeveloping
Joined: 16 Feb 2015
Total Posts: 740
01 Jul 2015 10:51 AM
credits.Changed:connect(function(value)
if rank < 5 then
if tonumber(credits.Value) > rank * 5 then
credits.Value = ds:GetAsync(player.userId .. '_Credits')
end
elseif rank >= 5 and rank < 10 then
if tonumber(credits.Value) > (20 + ((rank-4) * 8)) then
credits.Value = ds:GetAsync(player.userId .. '_Credits')
end
elseif rank > 10 then
ds:SetAsync(player.userId .. '_Credits', value)
end
wait(1)
ds:SetAsync(player.userId .. '_Credits', value)
end)

The problem is probably here (My best guess).
You see, when you change the value, it either applies to
tonumber(credits.Value) > rank * 5,
tonumber(credits.Value) > (20 + ((rank-4) * 8)),
and here it says
elseif rank > 10 then
ds:SetAsync(player.userId .. '_Credits', value)
end

Since you are over rank 10, it saves your credits instantly.
But for people who is less than rank 10, it applies to one of the both.
You see when you change the value of the lower ranks, it loads their old stats.
credits.Value = ds:GetAsync(player.userId .. '_Credits') or 0 <- This still causes .Changed to occur
So when their credits changed, their old data will be brought back up because of credits.Value = ds:GetAsync(player.userId .. '_Credits').
Report Abuse
devTools is online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
01 Jul 2015 11:18 AM
Nope because I tested it on a few LRs... idk why it's not working lol.



| devTools || You can't flame a man on fire |
Report Abuse
devTools is online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
01 Jul 2015 11:23 AM
Like, I'm not exactly following everything you just said lol. I thought that it would get their previous stat when it does the ds:GetAsync, and their previous stat would be the one that was just updated so that it can't be AAed



| devTools || You can't flame a man on fire |
Report Abuse
devTools is online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
01 Jul 2015 12:54 PM
b



| devTools || You can't flame a man on fire |
Report Abuse
devTools is online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
01 Jul 2015 12:59 PM
u



| devTools || You can't flame a man on fire |
Report Abuse
devTools is online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
01 Jul 2015 01:03 PM
m



| devTools || You can't flame a man on fire |
Report Abuse
CrowClaws is not online. CrowClaws
Joined: 04 Jul 2010
Total Posts: 4466
01 Jul 2015 01:05 PM
a better way of doing this is to save the actual values object in some random folder deep in serverstorage so no one can acsess it, and just make the leaderboard stats strings that copy whatever those intvalues say. therefor if they change there value in the leaderboard it won't actually affect anything
Report Abuse
devTools is online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
01 Jul 2015 01:07 PM
p



| devTools || You can't flame a man on fire |
Report Abuse
devTools is online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
01 Jul 2015 01:09 PM
@crow
I want their new stats to save tho, so I am just trying to give it parameters before it saves. I basically just want it to run this math before it saves and if the math shows it's too many credits, then they go back to what they had before it was changed.



| devTools || You can't flame a man on fire |
Report Abuse
devTools is online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
01 Jul 2015 01:14 PM
bu



| devTools || You can't flame a man on fire |
Report Abuse
devTools is online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
01 Jul 2015 01:23 PM
mp



| devTools || You can't flame a man on fire |
Report Abuse
devTools is online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
01 Jul 2015 01:29 PM
b u m p



| devTools || You can't flame a man on fire |
Report Abuse
devTools is online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
01 Jul 2015 01:33 PM
Anyone else?



| devTools || You can't flame a man on fire |
Report Abuse
devTools is online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
01 Jul 2015 02:57 PM
bummpppp



| devTools || You can't flame a man on fire |
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image