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

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

Asked by 8 years ago

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

Log in to vote
1
Answered by 8 years ago

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)

Ad

Answer this question