Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

1 comment

0

Thank you very much! :)

This discussion is preserved as it was. New answers, comments, and votes are closed.