"19:25:14.186 - Workspace.Part.Script:5: attempt to perform arithmetic on local 'cash' (a userdata value)"
script.Parent.Touched:connect(function(hit) hit.Parent:WaitForChild("Humanoid") local plr = hit.Parent.PlayerLocation.Value local cash = plr.leaderstats.Cash cash = cash + 5 end)
Answered by: gioni01
script.Parent.Touched:connect(function(hit) hit.Parent:WaitForChild("Humanoid") local plr = hit.Parent.PlayerLocation.Value local cash = plr.leaderstats.Cash cash.Value = cash.Value + 5 end)
You are trying to set the object "cash" to a new value, when you're wanting to set the value of its property.
script.Parent.Touched:connect(function(hit) hit.Parent:WaitForChild("Humanoid") local plr = hit.Parent.PlayerLocation.Value local cash = plr.leaderstats.Cash cash.Value = cash.Value + 5 end)
You are trying to access the cash value instance, not the value itself. Put a ".value" after Cash.
script.Parent.Touched:connect(function(hit) hit.Parent:WaitForChild("Humanoid") local plr = hit.Parent.PlayerLocation.Value local cash = plr.leaderstats.Cash cash.Value = cash.Value + 5 end)