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

Unable to cast Instance to CoordinateFrame?

Asked by 5 years ago

so i am trying to change a part position randomly and i am trying to set a PrimaryCFrame to move a model here is my code

1while true do
2script.Parent:SetPrimaryPartCFrame(script.Parent.Main)
3wait(0.5)
4end

any help given is appreciated

1 answer

Log in to vote
1
Answered by 5 years ago

well, the :SetPrimaryPartCFrame() needs a CFrame to set the model's CFrame, so either make a CFrame.new() with the parts position or make the set primary part cframe to the parts cframe, e.g

1while true do
2    script.Parent:SetPrimaryPartCFrame(CFrame.new(script.Parent.Main.Position))
3    wait(0.5)
4    -- NOTE: MAKE SURE 'MAIN' IS NOT A MODEL
5end

OR:

1while true do
2    script.Parent:SetPrimaryPartCFrame(script.Parent.Main.CFrame)
3    wait(0.5)
4    -- NOTE: MAKE SURE 'MAIN' IS NOT A MODEL
5end
0
Someone give this main the solution :weary: Also, you should note next time that he's trying to cast a value to an instance, which makes no sense syntactically :P   Psudar 882 — 5y
Ad

Answer this question