I want to change player leaderstats when touching part and error error code:
09:29:18.457 - Workspace.Finish.Part.Script:4: attempt to perform arithmetic (add) on userdata and number
09:29:18.459 - Stack Begin
09:29:18.460 - Script 'Workspace.Finish.Part.Script', Line 4
09:29:18.461 - Stack End
This is the script:
script.Parent.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then player.leaderstats.Finish = player.leaderstats.Finish + 1 player.data.cash = player.data.cash + 50 end end)
Easy quick fix! Add .Value
to access its value!
script.Parent.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then player.leaderstats.Finish.Value = player.leaderstats.Finish.Value + 1 player.data.cash.Value = player.data.cash.Value + 50 end end)