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

Issue about changing Angles?

Asked by
Paldi 109
6 years ago

Hello, i'm making a script for a door that when i click it, the PrimaryPart of the door rotates so the door "opens", but i'm not really used with radians and all that so now when i click it, the door goes open at 90 degress then when i try to close it i goes around the other way and i dont know how to fix that, any help is welcome!

    if touch == false and db == false then
        touch = true
        db = true
        door.PrimaryPart = door.Middle
        local dpos = door.PrimaryPart.Position
        door:SetPrimaryPartCFrame(CFrame.new(door.PrimaryPart.Position)* CFrame.Angles(0,door.PrimaryPart.Rotation.y+math.rad(90),0))
        wait(.5)
        db = false
    elseif touch == true and db == false then
        touch = false
        db = true
        door.PrimaryPart = door.Middle
        local dpos = door.PrimaryPart.Position
        door:SetPrimaryPartCFrame(CFrame.new(door.PrimaryPart.Position)* CFrame.Angles(0,door.PrimaryPart.Rotation.y-math.rad(90),0))
        wait(.5)
        db = false
    end
0
Isn't' that what you wanted it to do? hiimgoodpack 2009 — 6y
0
well not really, i mean the door instead of going back to 0 degree it will go to something else then start going in weird rotations Paldi 109 — 6y
0
Have you tried setting the CFrame.Angles to (0,math.rad(90),0) and then the closing to (0,math,rad(-90),0)? AmWrath 41 — 6y
0
yes but it i would need to edit the script for every door i place to make sure it opens on the good angle or else if i make the door face another way it wont open it correctly Paldi 109 — 6y

Answer this question