I'm trying to make a reset block so when the player touches this part, their leaderstats will restart. But it doesn't work.
1 | function onTouched(hit) |
2 | local player = game:GetService( "Players" ):GetPlayerFromCharacter(hit.Parent) |
3 | if player then |
4 | player.leaderstats.Cash.Value = 0 |
5 | end |
6 | end |
You forgot to add a "Touched Event" onto your script. This should work:
1 | function onTouched(hit) |
2 | local player = game:GetService( "Players" ):GetPlayerFromCharacter(hit.Parent) |
3 | if player then |
4 | player.leaderstats.Cash.Value = 0 |
5 | end |
6 | end |
7 | script.Parent.Touched:Connect(onTouched) |
Hope this helps, LennyPlayzYT