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

? if door2.Position==Vector3.new(-77.5, 21.12, 20.75) then | isn't working :( | ROBLOX LUA |

Asked by 7 years ago
1function onClicked(playerWhoClicked)
2    if door2.Position==Vector3.new(-77.5, 21.12, 20.75) then
3    for i = 1,60 do
4        wait()
5        door.CFrame = door.CFrame - Vector3.new(0, 0.2, 0)
6        door2.CFrame = door2.CFrame - Vector3.new(0, 0.2, 0)
7    end
8end

Hello! I need a bit of help on 'if door2.Position==Vector3.new() then', I do not understand what's wrong, as isn't vector3 = X,Y,Z. and aren't these inputs X,Y,Z? I'm honestly really confused and if anyone can reply that would be amazing!

(Apologies for the disgusting code in advance xd), again please reply!

Thanks, userdetail super super bad scripter.

0
I would just make a variable local atPosition = false and you set it when it reaches that position blowup999 659 — 7y

1 answer

Log in to vote
-1
Answered by
OfcPedroo 396 Moderation Voter
7 years ago
Edited 7 years ago

Hey, I'll give it a try

Checking for Vector3, UDim2 and CFrame isn't easy, but that's not how you check them.

Here, try the following script.

01function onClicked(playerWhoClicked)
02    --if door2.Position==Vector3(-77.5, 21.12, 20.75) then //You can't check Vector3 with Vector3.new, you have to check each. Look now.
03    if door2.Position.X = -77.5 then
04        if door2.Position.Y = 21.12 then
05            if door2.Position.Z = 20.75 then
06                for i = 1,60 do
07                    wait()
08                    door.CFrame = door.CFrame - Vector3.new(0, 0.2, 0)
09                    door2.CFrame = door2.CFrame - Vector3.new(0, 0.2, 0)
10            end
11        end
12    end
13end
14 
15--Remember, you only use the Position.X, Y, Z method when you're CHECKING something (if). When you're setting a position, you'll use what you were using, Vector3.new (X, Y, Z)

Got your error? Understood it?

If it works, please mark this as the solution

As always, good scripting! :D

0
Who gave -1 to my answer? It has to be working! .-. OfcPedroo 396 — 7y
Ad

Answer this question