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.
Hello, try to not use Vector3.new() which defines new position, try this one:
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 tostring(door.Position) == "36.925, 2.975, 40.4" then -- Try to not use Vector3.new doorfunc.Open() door.Open:Play() elseif tostring(door.Position) == "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)