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

when i use :SetPrimaryPartCFrame() Unable to cast double to CoordinateFrame comes up in output?

Well here is the segment of my script where i need to move the whole model

script.Parent.Touched:connect(function(hit)
	if hit.Name == ("Win") then
		script.Parent.Parent:SetPrimaryPartCFrame(1,1,1)
		wait(0.3)
	end
end)

then when character(the name of the model) touches "win" Unable to cast double to CoordinateFrame comes up in output and i dont understand why. Thank you for you help

2 answers

✓ Accepted answer

You need a CFrame (CoordinateFrame), not just 3 parameters. It is like how you cannot move a part like this

workspace.Part.Position = 1, 10, 1

but instead, you have to do

workspace.Part.Position = Vector3.new(1, 10, 1)

Now, for a CFrame, you would do

script.Parent.Touched:connect(function(hit)
    if hit.Name == ("Win") then
        script.Parent.Parent:SetPrimaryPartCFrame(CFrame.new(1,1,1))
        --The wait is unnecessary, as it does nothing.
    end
end)

Also, read my bio and do what it says. Don't indent with spaces.

The reason this error is occuring is because the funcition SetPrimaryPartCFrame() requires a CFrame to be given, you are giving it (1,1,1) which is just numbers. To fix this we need to give it a CFrame()

script.Parent.Touched:connect(function(hit)
    if hit.Name == ("Win") then
        script.Parent.Parent:SetPrimaryPartCFrame(CFrame.new(1,1,1)) --Notice how im giving it a cframe
        wait(0.3)
    end
end)

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