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.
01 | reset.MouseButton 1 Down:connect( function () |
02 | for i,v in pairs (game.Players:GetPlayers()) do |
03 | for k,val in pairs (v.leaderstats:GetChildren()) do |
04 | if val:IsA( "IntValue" ) then |
05 | val.Value = 0 |
06 | elseif val:IsA( "StringValue" ) and val.Name = = "Promotion" then |
07 | val.Value = "No" |
08 | end |
09 | end |
10 | end |
11 | 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..
01 | function reset() |
02 | for i,v in pairs (game.Players:GetPlayers()) do |
03 | for k,val in pairs (v.leaderstats:GetChildren()) do |
04 | if val:IsA( "IntValue" ) then |
05 | val.Value = 0 |
06 | elseif val:IsA( "StringValue" ) and val.Name = = "Promotion" then |
07 | val.Value = "No" |
08 | end |
09 | end |
10 | end |
11 | end |
12 |
13 | script.Parent.MouseButton 1 Down: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.