i made this script that assigns values to states of hiding
0 to not hiding
1 to hiding with the door open
2 to hiding with the door closed
problem is the script cant update the values properly
local Players = game:GetService("Players")
script.Parent.Touched:Connect(function(hit)
local plr = Players:GetPlayerFromCharacter(hit.Parent)
local char = plr.Character
if script.Parent.Parent.door.CFrame == script.Parent.Parent.door.open.CFrame and hit.Name == "HumanoidRootPart" then
char.hidden.Value = 1
end
if script.Parent.Parent.door.CFrame == script.Parent.Parent.door.close.CFrame and hit.Name == "HumanoidRootPart" then
char.hidden.Value = 2
end
end)
script.Parent.TouchEnded:Connect(function(hit)
if hit.Name == "HumanoidRootPart" then
local plr = Players:GetPlayerFromCharacter(hit.Parent)
local char = plr.Character
char.hidden.Value = 0
end
end)```