Why are my remote scripts not setting my values to false?
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:
1 | local repstorage = game:GetService( "ReplicatedStorage" ) |
2 | local remote = repstorage:WaitForChild( "Remote2" ) |
5 | local plr = hit.Parent.Name |
6 | remote:FireClient(game.Players:WaitForChild(plr)) |
8 | script.Parent.Touched:Connect(onTouch) |
Local Script in PlayerGui:
1 | local repstorage = game:GetService( "ReplicatedStorage" ) |
2 | local remote = repstorage:WaitForChild( "Remote2" ) |
4 | remote.OnClientEvent:connect( function (first) |
5 | script.Parent.Parent.Backpack.Ineatbox.Value = true |
6 | if script.Parent.Creature.Creature.Value = = "Single-Celled Organism" and script.Parent.Parent.Backpack.Ineatbox.Value = = true then |
7 | script.Parent.Parent.Backpack.Eating.Value = true |
The other script is the touch end script which should disable both values which will stop the food level from going up:
1 | local function TouchEndeds(hit) |
2 | local plr = hit.Parent.Name |
3 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
4 | game.Players:WaitForChild(plr).Backpack.Eating.Value = false |
5 | game.Players:WaitForChild(plr).Backpack.Ineatbox.Value = false |
8 | 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.