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?

01local FPD = false -- First Part Down, tells the script when the first section has been placed.
02 
03local parentHere = workspace.RoomFolder
04local cells = game.ReplicatedStorage:GetChildren()
05for i, v in pairs(cells) do
06v.PrimaryPart = v.Start
07end
08    for y = 1, 4, 1 do
09    local cell = cells[math.random(#cells)]:clone()
10    cell.Parent = parentHere
11 
12        if FPD == true then
13        local pos = script.NextPosition.Value
14        cell:MoveTo(pos)
15        script.NextPosition.Value = cell.Finish.CFrame
View all 26 lines...

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