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

How can I make a door move via CFrame without unioning it?

Asked by
Webm07 43
7 years ago

I don't know how to do CFrame for a door with a lot of parts, but unioning it is the only way I can get it working. How do I do that?

local cf = script.Parent.CFrame
function onClicked()
    if script.IsOpened.Value == false and script.IsOpening.Value == false then
        script.IsOpening.Value = true
        for i = 1,16 do
            script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, -0.18) * CFrame.fromEulerAnglesXYZ(0, -0.1, 0)
            wait(0.01)
        end
        script.IsOpening.Value = false
        script.IsOpened.Value = true
    elseif script.IsOpened.Value == true and script.IsOpening.Value == false then
        script.IsOpening.Value = true
        for i = 1,16 do
            script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, 0.18) * CFrame.fromEulerAnglesXYZ(0, 0.1, 0)
            wait(0.01)
        end
        script.IsOpening.Value = false
        script.IsOpened.Value = false
        script.Parent.CFrame = cf
        script.CloseSound:Play()
    end
end
--script.Parent.ClickDetector.MouseClick:connect(onClicked)
script.Parent.Touched:connect(onClicked)


while true do
    wait(15)
    if script.IsOpened.Value == true then
        script.IsOpening.Value = true
        for i = 1,16 do
            script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, 0.18) * CFrame.fromEulerAnglesXYZ(0, 0.1, 0)
            wait(0.01)
        end
        script.IsOpening.Value = false
        script.IsOpened.Value = false
        script.Parent.CFrame = cf
    end
end

0
Try welding the parts in the model to a part to act as a hinge. It would be much easier. aero9497 0 — 7y
0
I'll try it out Webm07 43 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Group the parts of the door together, set a primary part of the model, and use

Model:SetPrimaryPartCFrame(CFrame)

to move the whole model together.

0
I’ll try it out. Thank you. Webm07 43 — 7y
Ad

Answer this question