✓ Accepted answer
I think you are using a ClickDetector. There are a couple of things to note down:
- You can only use the LocalPlayer in a localscript that is inside the player, startergui etc.
- The MouseClick Event for the ClickDetector comes with a parameter “player” which gives the player that clicked.
- If you are making a hunger eating system it may be important to include Debounce.
Anyways let’s dive in. So basically your getting the LocalPlayer from a script in workspace. You can never get the LocalPlayer that way, you can only get it in a LocalScript that is under the various player folders like StarterGui, StarterPack, etc.
But since you are using a ClickDetector, it comes with a parameter that tells you which player clicked. I’ll provide a roblox link for events and such.
Your script fixed should be:
script.Parent.MouseClick:Connect(function(Player)
game.Players.Player.PlayerGui.Stats.Hunger_Stat.Hunger_Amount = game.Players.Player.PlayerGui.Stats.Hunger_Stat.Hunger_Amount + 25
end)
You can ask questions any time in the comments
3 comments
https://developer.roblox.com/en-us/articles/events Here’s a link for roblox events. I think you might understand, tell me if you don’t.
Hmm, thanks
No problem