Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I check a part's position?

Asked by 3 years ago

I'm trying to make a sliding door and I can't figure out how to check for the door's position.

01local part = script.Parent
02local door = script.Parent.Parent.Door
03local debounce = false
04local 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 == Vector3.new(36.925, 2.975, 40.4) then
11            doorfunc.Open()
12            door.Open:Play()
13            elseif door.Position == Vector3.new(36.925, 8.675, 40.4) then
14            doorfunc.Close()
15            door.Close:Play()
View all 25 lines...

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.

0
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? az1339and339 0 — 3y
0
debounce is basically a delay so that people can't spam something Zeta_Dev 34 — 3y
0
If you want to explain debounce function in script, contact me on discord - lukiny9000_2#0558 BeautifulAuraLover 371 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

Hello, try to not use Vector3.new() which defines new position, try this one:

01local part = script.Parent
02local door = script.Parent.Parent.Door
03local debounce = false
04local 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()
View all 25 lines...
0
It is still printing position is not found or is either moving after I applied your edits. Zeta_Dev 34 — 3y
Ad

Answer this question