Whenever I run this in studio everything works perfect and resets the values, but if I run it by going to the place and clicking Play. It doesn't reset any values.
reset.MouseButton1Down:connect(function() for i,v in pairs(game.Players:GetPlayers()) do for k,val in pairs(v.leaderstats:GetChildren()) do if val:IsA("IntValue") then val.Value=0 elseif val:IsA("StringValue") and val.Name=="Promotion" then val.Value="No" end end end end)
Part of a larger code.
In the code you provided, you didn't define 'reset' on line 1. It's nil. Unless you meant to make a connection statement, in that case you would have to do..
function reset() for i,v in pairs(game.Players:GetPlayers()) do for k,val in pairs(v.leaderstats:GetChildren()) do if val:IsA("IntValue") then val.Value=0 elseif val:IsA("StringValue") and val.Name=="Promotion" then val.Value="No" end end end end script.Parent.MouseButton1Down:connect(reset)
But ultimately, we can't help you unless you supply the whole script, and output if there is any.
Make sure this is a localscript.