script.Parent.MouseClick:Connect(function() game.Players.LocalPlayer.PlayerGui.Stats.Hunger_Stat.Hunger_Amount = game.Players.LocalPlayer.PlayerGui.Stats.Hunger_Stat.Hunger_Amount + 25 end)
It says local player wasnt found, but i need the food to go to only the local players Gui, anybody know how to do this?
Im using a non local script, and the script is inside the parent.
I think you are using a ClickDetector. There are a couple of things to note down:
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