the local script
local remote = game.ReplicatedStorage.Roll local ls = game.Players.LocalPlayer.leaderstats:WaitForChild("Rolls") game.ReplicatedStorage.Roll.OnClientEvent:Connect(function() for _, v in pairs (ls) do if v:IsA("IntValue") then v.Value += 1 end end ls.Value = ls.Value + 1 end)
error on line 5: invalid argument #1 to 'pairs' (table expected, got Instance)????
Problem
You are attempting to iterate through an Instance instead of the required table.
The error itself means you are providing an Instance where you should be providing a table. The error also provides a location as to where you are providing an Instance instead of a table (line 5).
Solution
In your situation, using the :GetChildren() or :GetDescendants() methods will solve your issue as both of these methods return tables.
Code
local remote = game.ReplicatedStorage.Roll local ls = game.Players.LocalPlayer.leaderstats:WaitForChild("Rolls") game.ReplicatedStorage.Roll.OnClientEvent:Connect(function() for _, v in pairs (ls:GetChildren()) do -- Added :GetChildren() if v:IsA("IntValue") then v.Value += 1 end end ls.Value = ls.Value + 1 end)
Conclusion
If you are confused by anything in this answer, or have more questions, feel free to contact me though my Discord server