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

So close to working, just need help with moving entire models [?]

I just need to know how to move models with scripts

Obbys = {"Spin Tube","Ice Path","Laser1"}

function Cool()
local Obby = game.Lighting:FindFirstChild(Obbys[math.random(1,3)])
local Boo = Obby:Clone()
Boo.Parent = game.Workspace
Boo:MakeJoints()
Boo.PrimaryPart = Boo.BaseArea
Boo:SetPrimaryPartCFrame(script.Parent.Parent.BaseArea.CFrame + CFrame.new(56,0,0))
script:Destroy()
end

script.Parent.Touched:connect(Cool)

Errors:

Workspace.Model.SpawnLocation.Script:9: bad argument #2 to '?' (Vector3 expected, got CFrame)

1 answer

Okay, first you should tab your code.

Now, you real problem is your CFrame math. You cannot add a CFrame to a CFrame. You must multiply which will still do the same thing you want.

So bellow is the fixed code.

Obbys = {"Spin Tube","Ice Path","Laser1"}

function Cool()
	local Obby = game.Lighting:FindFirstChild(Obbys[math.random(1,3)])
	local Boo = Obby:Clone()
	Boo.Parent = game.Workspace
	Boo:MakeJoints()
	Boo.PrimaryPart = Boo.BaseArea
	Boo:SetPrimaryPartCFrame(script.Parent.Parent.BaseArea.CFrame * CFrame.new(56,0,0))
	script:Destroy()
end

script.Parent.Touched:connect(Cool)

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