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.
First of all, you have an argument that doesnt exist on the local script for the onclient event. Also all values (unless its a variable) should be set via a server script.Unless you want that value to be changed only with that client.
You're firing a remote event to a local script. Remote events are from local to global. If you wish, you can use a remote event, fire it to a global script, which does the same thing to the player, ie, setting your value to false.