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

How do i make a part teleport to another part?

i want this model called Killer to move to the model called Dyno

here is my script so far:

local model = workspace.Dyno
model.PrimaryPart = model:FindFirstChild("middlePart")
local Offset = model:GetPrimaryPartCFrame()
local replicatedStorage = game:GetService("ReplicatedStorage")
local killB = replicatedStorage.Killer
local copy = killB:Clone()
copy.Parent = model.Parent
copy.Name = "Explosions"
copy.PrimaryPart = copy:FindFirstChild("Part")
copy:SetPrimaryPartCFrame(CFrame.new(Offset))

whenever i run it it says: 15:20:45.971 - Workspace.Dyno.Sticks.Script:10: bad argument #1 to 'new' (Vector3 expected, got CFrame)

please help

1 comment

0

Try setting the CFrame for line 10 as Offset only: copy:SetPrimaryPartCFrame(Offset)

1 answer

✓ Accepted answer

The Problem


Well the reason this error is appearing is that you are trying to convert a cframe into another cframe.

the reason for this is the CFrame.new here :

copy:SetPrimaryPartCFrame(CFrame.new(Offset))

as you already defined Offset as model:GetPrimaryPartCFrame(), and CFrame.new() doesn't accept another cframe as a parameter in any form, it will error.


Solution


To get around this, you could just get rid of the cframe.new:

local Offset = model:GetPrimaryPartCFrame()
copy:SetPrimaryPartCFrame(Offset)

1 comment

0

Thank You so much!

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