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

I have a script to make my door open, But it doesn't work! Can someone help?

Asked by
s_21 74
6 years ago

So, I've got this script in the 'Door' Union in a model. In the same model we have 2 Unions named 'Button1' and 'Button2' These 2 Button Unions both have ClickDetector In them. Can someone please fix this script to make the door open. Thank you.


local KCA = script.Parent.Parent.SoundPart["KeyCard Accepted"] local KCD = script.Parent.Parent.SoundPart["KeyCard Denied"] local DO = script.Parent.Parent.SoundPart.DoorOpen local DC = script.Parent.Parent.SoundPart.DoorClose local door = script.Parent local bool = true local bool2 = true function openDoor() KCA:Play() KCD:Stop() DO:Play() script.Parent.Parent["Light 1"].BrickColor=BrickColor.Green() script.Parent.Parent["Light 2"].BrickColor=BrickColor.Green() for i = 1,(door.Size.z / 0.30) do wait() door.CFrame = door.CFrame - (door.CFrame.lookVector * 0.30) endhttps://assetgame.roblox.com/asset/?id=182529039#assetTypeId=10Military Canvas Tent image wait(3) DC:Play() for i = 1,(door.Size.z / 0.30) do wait() door.CFrame = door.CFrame + (door.CFrame.lookVector * 0.30) end script.Parent.Parent["Light 1"].BrickColor=BrickColor.Red() script.Parent.Parent["Light 2"].BrickColor=BrickColor.Red() end script.Parent.workspace.Door["Button1"].ClickDetector.MouseClick:connect(function() if bool then bool = false openDoor() wait(1) bool = true end end) script.Parent.workspace.Door["Button2"].ClickDetector.MouseClick:connect(function() if bool then bool = false openDoor() wait(1) bool = true end end)
0
Is there anything in the output rilgundam 65 — 6y
0
Is there anything in the output rilgundam 65 — 6y
1
Yes, errors are important to fixing the script. Please show us some. gitrog 326 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

script.Parent.workspace.Door

Ok, so you messed up there.

What you need to do is to change "script.Parent.workspace.Door" to "workspace.Door" or "script.Parent.Parent.Door" at lines 39 and 30.

This is because you cannot put a specific name as a Parent, or it will try to find "workspace" inside your script's parent.

script.Parent.Parent.Door["Button1"].ClickDetector.MouseClick:connect(function()
    if bool then
        bool = false
        openDoor()
        wait(1)
        bool = true
    end
end)


script.Parent.Parent.Door["Button2"].ClickDetector.MouseClick:connect(function()
    if bool then
        bool = false
        openDoor()
        wait(1)
        bool = true
    end
end)

Ad

Answer this question