So, we have a special currency system in our game and it all works fine, but when said amount of 10 points are subtracted it subtracts, but when the points automatically update within 5 seconds, it reverts back to the old amount and adds 5, how can it be stopped from reverting?
Link to GIF: https://gyazo.com/a3a7e58a86a16c449dea3c5708a327ef
MilesAdding Script:
--Config Scripts--
amount = 5
timedelay = 5
currencyname = "SkyMiles"
--Script--
while true do
wait(timedelay)
for i,v in pairs(game.Players:GetPlayers()) do
if v:FindFirstChild("leaderstats") then
v.leaderstats[currencyname].Value = v.leaderstats[currencyname].Value + amount
end
end
end
Leaderboard and Saving Script:
local dStore = game:GetService("DataStoreService"):GetDataStore("SkyFlySavingModule")
function createLeaderboard(plr)
local ls = Instance.new("IntValue")
ls.Name = "leaderstats"
local pts = Instance.new("IntValue")
pts.Parent = ls
pts.Name = "SkyMiles"
ls.Parent = plr
end
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:connect(function(char)
createLeaderboard(plr)
local save = dStore:GetAsync(plr.UserId.."_SAVE")
if save ~= nil then
plr.leaderstats.SkyMiles.Value = save
end
end)
end)
game.Players.PlayerRemoving:Connect(function(plr)
local saving = plr.leaderstats.SkyMiles.Value
dStore:SetAsync(plr.UserId.."_SAVE",saving)
end)
game:BindToClose(function()
wait(5)
end)
Shop Script:
local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function(click)
if plr.leaderstats.SkyMiles.Value >= 10 then
plr.leaderstats.SkyMiles.Value = plr.leaderstats.SkyMiles.Value - 10
local PasswordGUI = script.Parent.Parent.TweenGUIPassword
PasswordGUI:TweenPosition(UDim2.new(0.25,0,0.25,0),"Out","Elastic",1,true)
local BuyTestUI = script.Parent.Parent.Parent.MainFrame
BuyTestUI:TweenPosition(UDim2.new(2,0,0,0),"Out","Elastic",1,true)
end
end)

1 comment
Any help, please guys?