Hello! So I was recently hired to make a Reset Button for this guys Stat’s in game. While yes the normal leaderstat resets work, I am running into the stat called “Robux” not resetting also. Heres what it looks like:
Here is the Explorer View of while in the game:

Then lastly here is the Script I made:
script.Parent.Activated:Connect(function()
local username = script.Parent.Parent.Player.Text
local player = game.Players:FindFirstChild(username)
if player then
local leaderstats = player:FindFirstChild("Robux")
if leaderstats then
if leaderstats and leaderstats.Value > 0 then
leaderstats.Value = 0
end
end
end
end)
I have tried multiple thing’s but can’t seem to get it to reset it.
Anyone know why it’s not working or can help me fix it?
So your problem is, leaderstats are resseting, but Robux Value isnt?
Well I made this part specifically to reset the Robux Value, but yes
Well, you reset leaderstats value, instead of robux value. Try:
script.Parent.Activated:Connect(function()
local username = script.Parent.Parent.Player.Text
local player = game.Players:FindFirstChild(username)
if player then
player.Robux.Value = 0
end
end)
It looks like it’s trying to work. So what happens now is when I spam it, you can see it goes to 0 for like a fraction of a second, but then goes back to the original number that was climbing.
Is there any other script changes the robux value? It might be the problem. Because in that script everything seems good?
Well here is the script I think that controls it.
local BLACKLISTED_USERNAMES = {
"ThePixeIDev",
"0",
-- add more usernames here as needed
}
local dataStoreService = game:GetService("DataStoreService")
local ds = dataStoreService:GetDataStore(game.ServerScriptService.Datastores.LeaderstatDatastore.Value)
spawn(function()
game["Run Service"].Stepped:Connect(function()
for i, v in pairs(game.Players:GetPlayers()) do
local Robux = v.Robux
Robux.Value = Robux.Value + 5
end
end)
end)
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr
local robux = Instance.new("NumberValue")
robux.Name = "Robux"
robux.Parent = plr
local raised = Instance.new("NumberValue")
raised.Name = "Raised"
raised.Parent = leaderstats
local donated = Instance.new("NumberValue")
donated.Name = "Donated"
donated.Parent = leaderstats
local robuxData, raisedData, donatedData
local success, errormessage = pcall(function()
robuxData = ds:GetAsync("robux-"..plr.UserId)
raisedData = ds:GetAsync("raised-"..plr.UserId)
donatedData = ds:GetAsync("donated-"..plr.UserId)
end)
if success then
robux.Value = robuxData
raised.Value = raisedData
donated.Value = donatedData
end
-- Check if the player is blacklisted
for _, username in ipairs(BLACKLISTED_USERNAMES) do
if plr.Name == username then
robux.Value = 0
raised.Value = 0
donated.Value = 0
ds:SetAsync("robux-"..plr.UserId, 0)
ds:SetAsync("raised-"..plr.UserId, 0)
ds:SetAsync("donated-"..plr.UserId, 0)
break
end
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local success, errormessage = pcall(function()
ds:SetAsync("robux-"..plr.UserId, plr.Robux.Value)
ds:SetAsync("raised-"..plr.UserId, plr.leaderstats.Raised.Value)
ds:SetAsync("donated-"..plr.UserId, plr.leaderstats.Donated.Value)
end)
end)
That’s the entire Leaderstat script from what he’s told me.
Here is the script that makes the problem:
spawn(function()
game["Run Service"].Stepped:Connect(function()
for i, v in pairs(game.Players:GetPlayers()) do
local Robux = v.Robux
Robux.Value = Robux.Value + 5
end
end)
end)
How would I fix this then? Any ideas?
Just try to remove it? If it doesn’t then tell us.
If I remove it it stops adding the Value though.
Yes, but did’nt you want to reset the value?
Well yes, but its for a Admin GUI. So I type in the user I want to reset the values for. So its a targeted thing. Though I still want there money to continue after I reset there stats from inside the GUI.
So this is for an admin gui and you just want the money to keep increasing for admins? And not for other players.
No, its a reset for a certain player.

So you type in the user’s username. Then it Resets there Robux Stat. So it reset’s it to 0. How ever they can keep earning after that. So they keep getting a +5 to there stats after the reset. Its just they go from 10000000+5+5+5+5 back to 0+5+5+5 and so forth. Hope that makes a little more sense.
So from what I understood, after you reset Value, you still want that player to gain it?
Yes. I still want them to continue getting a +5 just they restart from 0.
Can you try this? If the script is serverscript
local ds = dataStoreService:GetDataStore(game.ServerScriptService.Datastores.LeaderstatDatastore.Value)
script.Parent.Activated:Connect(function()
local username = script.Parent.Parent.Player.Text
local player = game.Players:FindFirstChild(username)
if player then
player.Robux.Value = 0
ds:SetAsync("robux-"..plr.UserId, 0)
end
end)
Oh the script is Client Side its a Child of the TextButton
leaderstats script:
local BLACKLISTED_USERNAMES = {
"ThePixeIDev",
"0",
-- add more usernames here as needed
}
local dataStoreService = game:GetService("DataStoreService")
local ds = dataStoreService:GetDataStore(game.ServerScriptService.Datastores.LeaderstatDatastore.Value)
local RemoteEvent = game:GetService("ReplicatedStorage").RemoteEvent
spawn(function()
game["Run Service"].Stepped:Connect(function()
for i, v in pairs(game.Players:GetPlayers()) do
local Robux = v.Robux
Robux.Value = Robux.Value + 5
RemoteEvent.OnServerEvent:Connect(function(Player,Name)
Player.Robux.Value = 0
end)
end
end)
end)
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr
local robux = Instance.new("NumberValue")
robux.Name = "Robux"
robux.Parent = plr
local raised = Instance.new("NumberValue")
raised.Name = "Raised"
raised.Parent = leaderstats
local donated = Instance.new("NumberValue")
donated.Name = "Donated"
donated.Parent = leaderstats
local robuxData, raisedData, donatedData
local success, errormessage = pcall(function()
robuxData = ds:GetAsync("robux-"..plr.UserId)
raisedData = ds:GetAsync("raised-"..plr.UserId)
donatedData = ds:GetAsync("donated-"..plr.UserId)
end)
if success then
robux.Value = robuxData
raised.Value = raisedData
donated.Value = donatedData
end
-- Check if the player is blacklisted
for _, username in ipairs(BLACKLISTED_USERNAMES) do
if plr.Name == username then
robux.Value = 0
raised.Value = 0
donated.Value = 0
ds:SetAsync("robux-"..plr.UserId, 0)
ds:SetAsync("raised-"..plr.UserId, 0)
ds:SetAsync("donated-"..plr.UserId, 0)
break
end
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local success, errormessage = pcall(function()
ds:SetAsync("robux-"..plr.UserId, plr.Robux.Value)
ds:SetAsync("raised-"..plr.UserId, plr.leaderstats.Raised.Value)
ds:SetAsync("donated-"..plr.UserId, plr.leaderstats.Donated.Value)
end)
end)
localScript:
local RemoteEvent = game:GetService("ReplicatedStorage").RemoteEvent
script.Parent.Activated:Connect(function()
local username = script.Parent.Parent.Player.Text
local Player = game.Players:FindFirstChild(username)
if Player then
RemoteEvent:FireServer(username)
end
end)
You need to create remoteevent in replicated storage