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

My door script isn't working, and this title isn't letting me say that alone?

Asked by 6 years ago

I made a script where my door is supposed to change position and rotation when it is clicked. It's not working and I don't know why. I kept looking for little details but nothing works. Here is my attempt at the script.

part = script.Parent
position = Vector3.new(0.65, 3.675, -26.85)
rotation = Vector3.new(0, 60, 0)
mainposition = Vector3.new(-0.45, 3.675, -28.45)
mainrotation = Vector3.new(0, 0, 0)

script.Parent.ClickDetector.MouseClick:connect(function(playerWhoClicked)
    if (part.Position == position and part.Orientation == rotation) then
        part.Position = part.Position.mainposition
        part.Orientation = part.Orientation.mainrotation
        part.CanCollide = true
    elseif (part.Position == mainposition and part.Orientation == mainrotation) then
        part.Position = part.Position.position
        part.Orientation = part.Orientation.rotation
        part.CanCollide = false
    else
        print("Door script failed.")
    end
end)
0
In the first If statement you say part.Position.mainposition when it seems like you were trying to access the variable "mainposition" you created at the beginning. Same with the mainrotation, position and rotation later in the script. Maybe try this: if (part.Position == position and part.Orientation == rotation) then    part.Position = mainposition    part.Orientation = mainrotation    part.CanCo Hamrhed2 4 — 6y
0
that's the exact thing I did Qualtshire 0 — 6y
0
well, before, I changed it because it wasn't working either. Qualtshire 0 — 6y
0
BTW why are you using a vector 3 for rotation? that will just move the part, not rotate it. Look into Cframe.Angles User#17125 0 — 6y
0
ohh ok thanks Qualtshire 0 — 6y

Answer this question