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

Moving Door Script. Not Working Properly. Any help? [Script Edited]

Asked by 9 years ago

This script here is suppose to [On clicked] move like a regular door would to open. Not making one part transparent and the other not. Like a realistic door movement. If you have ever played Vampire Hunters 2, it is suppose to be similar to those doors. However it isn't working. Im attempting to use SetPrimaryPart but im not sure if it is done correctly.

Script:

script.Parent.PrimaryPart = script.Parent.Main
local Main = script.Parent:SetPrimaryPartCFrame(CFrame.new(61.99, 4.04, 8.81))

function onClicked()
    if script.Parent.Open.Value == 1 then 
        for i = 0,1.5,0.1 do 
            wait(0.1)
            Main.CFrame = Main.CFrame*CFrame.fromEulerAnglesXYZ(0,-0.1,0)*CFrame.new(0.01,0,-0.25)
        end
            Main.CFrame = Main*CFrame.fromEulerAnglesXYZ(0,-math.pi/2,0)*CFrame.new(-2.5,0,-2.5)
            script.Parent.Open.Value = 0
        end
if script.Parent.Open.Value == 0 then
    for i = 0,1.5,0.1 do
        wait(0.1)
        Main.CFrame = Main.CFrame*CFrame.fromEulerAnglesXYZ(0,0.1,0)*CFrame.new(-0.01,0,0.25)
    end
        Main.CFrame = Main*CFrame.fromEulerAnglesXYZ(0,math.pi/2,0)*CFrame.new(-2.5,0,2.5)
        script.Parent.Open.Value = 1
    end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 answer

Log in to vote
0
Answered by 9 years ago

I tried setting this up, similar to you, maybe check console? Because when I do it, I get PrimaryPart is not a valid member of Part. Maybe try checking console and see if there's any errors. I hope this helped. :)

0
But also, I don't know how you set this up, so maybe it's just me, but check to see. :) theawesome624 100 — 9y
0
i posted another question, I got further in the script but however it breaks at a certain point CarterTheHippo 120 — 9y
Ad

Answer this question