I have a food part which has two scripts in them. One of them is the touch script which fires a remote event to a local script:
Script:
local repstorage = game:GetService("ReplicatedStorage")
local remote = repstorage:WaitForChild("Remote2")
function onTouch(hit)
local plr = hit.Parent.Name
remote:FireClient(game.Players:WaitForChild(plr))
end
script.Parent.Touched:Connect(onTouch)
Local Script in PlayerGui:
local repstorage = game:GetService("ReplicatedStorage")
local remote = repstorage:WaitForChild("Remote2")
remote.OnClientEvent:connect(function(first)
script.Parent.Parent.Backpack.Ineatbox.Value = true
if script.Parent.Creature.Creature.Value == "Single-Celled Organism" and script.Parent.Parent.Backpack.Ineatbox.Value == true then
script.Parent.Parent.Backpack.Eating.Value = true
end
end)
The other script is the touch end script which should disable both values which will stop the food level from going up:
local function TouchEndeds(hit)
local plr = hit.Parent.Name
if hit.Parent:FindFirstChild("Humanoid") then
game.Players:WaitForChild(plr).Backpack.Eating.Value = false
game.Players:WaitForChild(plr).Backpack.Ineatbox.Value = false
end
end
script.Parent.TouchEnded:Connect(TouchEndeds)
For some reason the Variables don't set to false which lets the food value continue to rise. Nothing is being output into the output. I am not too sure what to do to fix this so help would be appreciated.

1 comment
Wrong. Remote events can be from global to local.