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

I don't get what's wrong with the script?

Asked by
Nidoxs 190
9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

Why won't the door move?

Output 15:22:03.117 - Workspace.Model.Script:34: bad argument #2 to '?' (Vector3 expected, got userdata) 15:22:03.118 - Script 'Workspace.Model.Script', Line 34 15:22:03.120 - Stack End

local O = script.Parent.Open
local C = script.Parent.Close
local D = script.Parent.Union

opened = false 

function Door() 

if not opened then 

        opened = true 
        script.Parent.Cog1.Script.Disabled = false
        script.Parent.Cog2.Script.Disabled = false
        O.Sound:Play()     
        O.Transparency = 1
        C.Transparency = 0
        wait(5)
        for i = 1, 4600, -0.01 do       
        D.CFrame = Vector3.new(D.CFrame + CFrame.new(0,i,0))
        wait(.01)
        end 
    end 


if opened then 

        script.Parent.Cog1.Script.Disabled = true
        script.Parent.Cog2.Script.Disabled = true
        C.Sound:Play()       
        O.Transparency = 0
        C.Transparency = 1
        wait(5)
        for i = 1, 4600, 0.01 do        
        D.CFrame = Vector3.new(D.CFrame + CFrame.new(0,i,0))
        wait(.01)
        end 
    end 

        opened = false 

    end

script.Parent.Close.ClickDetector.MouseClick:connect(Door)

script.Parent.Open.ClickDetector.MouseClick:connect(Door)

1 answer

Log in to vote
1
Answered by
Merely 2122 Moderation Voter Community Moderator
9 years ago

On line 34, you're trying to set a CFrame to a Vector3. Just remove the Vector3.new() that surrounds your CFrame and the code should work. Also, since you're only wanting to move the brick upwards, and don't need the rotation, you can just add a Vector3 to the CFrame. A Vector3 is just a position, whereas a CFrame contains both positions and rotation data, which you don't need here.

D.CFrame =D.CFrame + Vector3.new(0,i,0)
0
Thank you very much! :) Nidoxs 190 — 9y
Ad

Answer this question