I'm trying to make a sliding door and I can't figure out how to check for the door's position.
local part = script.Parent
local door = script.Parent.Parent.Door
local debounce = false
local doorfunc = require(script.Parent.Parent.Door.ModuleScript)
script.Parent.Touched:Connect(function(hit)
if debounce == false then
debounce = true
if hit.Parent.level.Value >= 2 then
if door.Position == Vector3.new(36.925, 2.975, 40.4) then
doorfunc.Open()
door.Open:Play()
elseif door.Position == Vector3.new(36.925, 8.675, 40.4) then
doorfunc.Close()
door.Close:Play()
else print("Position is not found or is either moving")
end
end
if hit.Parent.level.Value <= 1 then
door.Audio:Play()
end
wait(1)
debounce = false
end
end)
This is what checks the door's position, but it doesn't function correctly. Also the module script has some tween animations in it to move the door.

3 comments
try putting print on each line to see what's the not working line+ i have a problem with debounce can you explain it if u can please?
debounce is basically a delay so that people can't spam something
If you want to explain debounce function in script, contact me on discord - lukiny9000_2#0558