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

Hwo would I amke it that it swings to the side?

Asked by 6 years ago

My friend made this door a while ago and we still use it. he ended up quitting roblox and gave me his models but i cant figure out how to make it that it goes to the side instead of opening in a opening like a normal door but have no idea how to edit the script like that. Any possible way to do it where it goes to the side instead?

local Model = script.Parent
local Handler = Model:WaitForChild("Handler")
local Knob = Model:WaitForChild("Knob")

local ClickDetector = Knob:WaitForChild("ClickDetector")

local AngleIncrement = 10 --change this to whatever you want, its how fast the door swings open/close
local WhitelistGroupIds = {}

local Open = false

function OpenDoor()
    for i=1, 360 / 4, AngleIncrement do
        for _,v in pairs(Model:GetChildren()) do
            if v:IsA("BasePart") then
                v.CFrame = (Handler.CFrame * CFrame.Angles(0, math.rad(AngleIncrement), 0)) * Handler.CFrame:toObjectSpace(v.CFrame)
            end
        end
        wait()
    end
    Open = true
end

function CloseDoor()
    for i=360 / 4, 1, -AngleIncrement do
        for _,v in pairs(Model:GetChildren()) do
            if v:IsA("BasePart") then
                v.CFrame = (Handler.CFrame * CFrame.Angles(0, math.rad(-AngleIncrement), 0)) * Handler.CFrame:toObjectSpace(v.CFrame)
            end
        end
        wait()
    end
    Open = false
end

function OpenCloseDoor()
    if not Open then
        OpenDoor()
    else
        CloseDoor()
    end
end

local debounce = false
ClickDetector.MouseClick:connect(function(plr)
    if debounce then return end
    debounce = true

    if #WhitelistGroupIds > 0 then
        for i=1, #WhitelistGroupIds do
            if plr:IsInGroup(WhitelistGroupIds[i]) then
                OpenCloseDoor()
            end
        end
    else
        OpenCloseDoor()
    end

    debounce = false
end)

1 answer

Log in to vote
0
Answered by 6 years ago

Dude, no point in editing this script, you HAVE to remake it from start. This script is all about turning the door at an angle. You would have to delete everything.

Look into part tweening for sliding doors : https://www.youtube.com/watch?v=qgGDwTn0zgo

0
Well, I am going to assume that he is talking about the doors that open at an angle, not sliding doors, I prefer to use set primary part cframe and then rotate it. Look up model rotation on youtube, it should come up with some good results TinyEndoskeletonGuy 0 — 6y
0
Nah dude, he specifically said "not like a normal door" User#17125 0 — 6y
Ad

Answer this question