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

Unable to cast CoordinateFrame to Vector3 please help?

Asked by
Memotag 226 Moderation Voter
6 years ago

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:

01wait(1)
02model = game.ReplicatedStorage.Tycoon1
03floor = script.Parent.Floor
04backup = model:Clone()
05backup.Parent = game.Workspace
06wait(0.1)
07backup:MoveTo(CFrame.new(floor.Position))
08 
09function Regen()
10model:remove()
11wait(1)
12model = backup:clone()
13model.Parent = script.Parent 
14model:makeJoints()
15end
View all 25 lines...

Any help is appreciated!

1 answer

Log in to vote
0
Answered by 6 years ago

This is because the argument to MoveTo is a Vector3, not a CFrame. However, you should be using SetPrimaryPartCFrame instead. Make sure a PrimaryPart is set, and use the method.

01wait(1)
02local model = game.ReplicatedStorage.Tycoon1
03local floor = script.Parent.Floor
04local backup = model:Clone()
05backup.Parent = game.Workspace
06wait(0.1)
07backup:SetPrimaryPartCFrame(CFrame.new(floor.Position))
08 
09local 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
15end
View all 26 lines...

On a side note, clone, makeJoints, and remove are deprecated, use Clone, MakeJoints, and Destroy instead.

0
Thank you for the help. Now I get 'Model:SetPrimaryCFrame() failed because no PrimaryPart has been set, or the PrimaryPart no longer exists. Please set Model.PrimaryPart before using this.' on Line 7 after making the changes. Any suggestions? Memotag 226 — 6y
0
I clearly stated to set a PrimaryPart before using the method. Set a PrimaryPart. User#19524 175 — 6y
Ad

Answer this question