So I have a local script inside a Gui (that I strictly cannot allow to reset after death) and whenever the player takes a seat or holds an item, the BoolValues will be set to true. However, it wasn’t working after death even if I referred the new character to the variable. I did fix it though, just wondering what’s the difference and why doesn’t the other one work…
I have encountered this issue so many times so I had to set it to reset some Guis after death that I worked on before. On this one, I really had no other choice, I can’t reset this Gui after death and I had to figure it out.
Working:
player.CharacterAdded:Connect(function(character)
char = character -- Replaces the local "char" variable with the new character
humanoid = char:WaitForChild("Humanoid")
holdingItem.Value = false
sitting.Value = false
char.ChildAdded:Connect(function(tool)
if tool:IsA("Tool") then
holdingItem.Value = true
end
end)
char.ChildRemoved:Connect(function(tool)
if tool:IsA("Tool") then
holdingItem.Value = false
end
end)
humanoid.Seated:Connect(function()
if humanoid.Sit == true then
sitting.Value = true
else
sitting.Value = false
end
end)
end)
Not working:
player.CharacterAdded:Connect(function(character)
char = character -- Replaces the local "char" variable with the new character
humanoid = char:WaitForChild("Humanoid")
holdingItem.Value = false
sitting.Value = false
end)
char.ChildAdded:Connect(function(tool)
if tool:IsA("Tool") then
holdingItem.Value = true
end
end)
char.ChildRemoved:Connect(function(tool)
if tool:IsA("Tool") then
holdingItem.Value = false
end
end)
humanoid.Seated:Connect(function()
if humanoid.Sit == true then
sitting.Value = true
else
sitting.Value = false
end
end)