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

Unable to cast Coordinate Frame to Vector3? Need help with a room generator script

Asked by 8 years ago

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

Log in to vote
2
Answered by
Link150 1355 Badge of Merit Moderation Voter
8 years ago

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.

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? ace12345678135 50 — 8y
0
it works now. thanks ace12345678135 50 — 8y
Ad

Answer this question