#Eating script stops working when I check if the hunger value is equal to or under 80

1 messages · Page 1 of 1 (latest)

atomic light
#

what type of script you are using?

#

normal script or local script?

neon hedge
atomic light
#

well server can't read the player text

#

so use local script instead

neon hedge
#

wdym i got the player

#

oh wait mb

#

mistake

#

it is local

lucid condor
#

Do it local

neon hedge
#

@atomic light

lucid condor
#

And always reference the tool

#

Don't do script.Parent

atomic light
#

and the Activated event doesn't have player as parameter

neon hedge
#

script.parent is the tool

lucid condor
atomic light
#

you should make a variable for that instead of type script.Parent many times

neon hedge
#

wait im stupid

#

i was looking at the wrong script 😭

#

it IS a server script

#

@atomic light

atomic light
#

bruh

neon hedge
#

mb

#

was looking at my hunger script and not the food script

atomic light
#
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local PlayerGui = player:WaitForChild("PlayerGui")

local HungerBar = PlayerGui:WaitForChild("HungerBar")
local currentNum = HungerBar:WaitForChild("CurrentValue")

local character = player.Character or player.CharacterAdded:Wait()
if not character then return end

local Tool = script.Parent

Tool.Activated:Connect(function()
    if currentNum.Value <= 80 then
        currentNum.Value = currentNum.Value + 20
        Tool:Destroy()
    end
end)

try to use this script from local script

neon hedge
#

ty it works

atomic light
#

np

neon hedge
#

i was using a server script so i could add other stuff like sounds and animations

#

but i guess ima have to use remote events for that