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

How do i make a part teleport to another part?

Asked by 5 years ago

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

0
Try setting the CFrame for line 10 as Offset only: copy:SetPrimaryPartCFrame(Offset) Troxure 87 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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)
0
Thank You so much! CubicleHead -3 — 5y
Ad

Answer this question