The idea of the script is to clone a model from 'ReplicatedStorage', take it to the Workspace and then place it in the same position as a baseplate. Right now the script will do everything as explained but it will also output the error ' Unable to cast CoordinateFrame to Vector3' and I have no idea on how to fix it.
Yes I am completely aware of deprecated parts of the script, I just want this issue solved.
Here is the code:
01 | wait( 1 ) |
02 | model = game.ReplicatedStorage.Tycoon 1 |
03 | floor = script.Parent.Floor |
04 | backup = model:Clone() |
05 | backup.Parent = game.Workspace |
06 | wait( 0.1 ) |
07 | backup:MoveTo(CFrame.new(floor.Position)) |
08 |
09 | function Regen() |
10 | model:remove() |
11 | wait( 1 ) |
12 | model = backup:clone() |
13 | model.Parent = script.Parent |
14 | model:makeJoints() |
15 | end |
Any help is appreciated!
MoveTo
is a Vector3
, not a CFrame
. However, you should be using SetPrimaryPartCFrame
instead. Make sure a PrimaryPart
is set, and use the method.01 | wait( 1 ) |
02 | local model = game.ReplicatedStorage.Tycoon 1 |
03 | local floor = script.Parent.Floor |
04 | local backup = model:Clone() |
05 | backup.Parent = game.Workspace |
06 | wait( 0.1 ) |
07 | backup:SetPrimaryPartCFrame(CFrame.new(floor.Position)) |
08 |
09 | local function Regen() |
10 | model:Destroy() -- remove is deprecated use Destry |
11 | wait( 1 ) |
12 | model = backup:Clone() -- clone is deprecated |
13 | model.Parent = script.Parent |
14 | model:MakeJoints() -- makeJoints deprecated |
15 | end |
clone
, makeJoints
, and remove
are deprecated, use Clone
, MakeJoints
, and Destroy
instead.