I'm trying to make a sliding door and I can't figure out how to check for the door's position.
01 | local part = script.Parent |
02 | local door = script.Parent.Parent.Door |
03 | local debounce = false |
04 | local doorfunc = require(script.Parent.Parent.Door.ModuleScript) |
05 |
06 | script.Parent.Touched:Connect( function (hit) |
07 | if debounce = = false then |
08 | debounce = true |
09 | if hit.Parent.level.Value > = 2 then |
10 | if door.Position = = Vector 3. new( 36.925 , 2.975 , 40.4 ) then |
11 | doorfunc.Open() |
12 | door.Open:Play() |
13 | elseif door.Position = = Vector 3. new( 36.925 , 8.675 , 40.4 ) then |
14 | doorfunc.Close() |
15 | door.Close:Play() |
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:
01 | local part = script.Parent |
02 | local door = script.Parent.Parent.Door |
03 | local debounce = false |
04 | local doorfunc = require(script.Parent.Parent.Door.ModuleScript) |
05 |
06 | script.Parent.Touched:Connect( function (hit) |
07 | if debounce = = false then |
08 | debounce = true |
09 | if hit.Parent.level.Value > = 2 then |
10 | if tostring (door.Position) = = "36.925, 2.975, 40.4" then -- Try to not use Vector3.new |
11 | doorfunc.Open() |
12 | door.Open:Play() |
13 | elseif tostring (door.Position) = = "36.925, 8.675, 40.4" then |
14 | doorfunc.Close() |
15 | door.Close:Play() |