Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i fix scripts working in studio but not in game when im using local player?

Asked by 7 years ago

I'm trying to make a game so that when you step on a hat it gives you RAP I tried this script it works in studio but not in-game is there any way to fix this

1function onTouched(hit)
2    local player = game.Players.LocalPlayer
3    player.leaderstats.RAP.Value=player.leaderstats.RAP.Value+90
4    script.Parent:Destroy()
5end
6 
7script.Parent.Touched:connect(onTouched)

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

game.Players.LocalPlayer only works in a local script not in a script so you can use the hit part of the function for example

1function onTouched(hit)
2local player = game.Players[hit.Parent.Name]
3player.leaderstats.RAP.Value=player.leaderstats.RAP.Value+90
4script.Parent:Destroy()
5end
6 
7script.Parent.Touched:connect(onTouched)

hoped this helps :)

0
Thanks it works now (: MasonTheCreeperYT3 74 — 7y
Ad

Answer this question