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

Unable to cast Instance to CoordinateFrame?

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

while true do
script.Parent:SetPrimaryPartCFrame(script.Parent.Main)
wait(0.5)
end

any help given is appreciated

1 answer

✓ Accepted answer

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

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

OR:

while true do
	script.Parent:SetPrimaryPartCFrame(script.Parent.Main.CFrame) 
	wait(0.5)
	-- NOTE: MAKE SURE 'MAIN' IS NOT A MODEL
end

1 comment

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  

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