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