local clickdetect = script.Parent:WaitForChild("ClickDetector") local HungerVal = game.Players.LocalPlayer:WaitForChild("HungerVal") clickdetect.MouseClick:Connect(function() print("test") HungerVal.Value = HungerVal.Value + 70 script.Parent.Parent:Destroy() if HungerVal.Value >100 then HungerVal.Value = 100 end end)
help i dont know whats wrong
u cant index localplayer from a server script.
as for the clickdetectors,
if u did this:
local clickdetect = script.Parent:WaitForChild("ClickDetector") clickdetect.MouseClick:Connect(function(plr) print(plr) end)
then it would print the player which clicked it. Now that u got the player u can go and define the hungerval inside the thing;
local clickdetect = script.Parent:WaitForChild("ClickDetector") clickdetect.MouseClick:Connect(function(plr) print(plr) local HungerVal = plr:FindFirstChild("HungerVal") HungerVal.Value = HungerVal.Value + 70 script.Parent.Parent:Destroy() if HungerVal.Value >100 then HungerVal.Value = 100 end end)
or something