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 Coordinate Frame to Vector3? Need help with a room generator script

Unable to cast Coordinate Frame to Vector3

The error is on line 22, what is the problem?

local FPD = false -- First Part Down, tells the script when the first section has been placed.

local parentHere = workspace.RoomFolder
local cells = game.ReplicatedStorage:GetChildren()
for i, v in pairs(cells) do
v.PrimaryPart = v.Start
end
	for y = 1, 4, 1 do
	local cell = cells[math.random(#cells)]:clone()
	cell.Parent = parentHere
	
		if FPD == true then
		local pos = script.NextPosition.Value
		cell:MoveTo(pos)
		script.NextPosition.Value = cell.Finish.CFrame
		end

		if FPD == false then
		local pos = workspace.RoomFolder.Begin.Finish.CFrame
		cell:MoveTo(pos)
		FPD = true
		script.NextPosition.Value = cell.Finish.CFrame
		end
wait(1)
		
end

1 answer

✓ Accepted answer

NextPosition is a Vector3Value object, you're trying to assign a CFrame value to its Value property. Assign it a Vector3 value and it will work fine. You can grab the position of a CFrame as a Vector3 value using its p component: cell.Finish.CFrame.p.

2 comments

0

thank you, just so you know the next position line is a CFrameValue i added inside the script and named NextPosition, didnt even know it was a part of lua code. Will your answer still work under the surcumstances?

0

it works now. thanks

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