for i,v in pairs(game.Workspace:GetDescendants()) do
if v.Name == "Spawnpoint" then
local ChosenSpawn = (v[math.random(1, #v)])
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = ChosenSpawn.CFrame
end
end
I'm trying to make a script so that it gets the descendants of the workspace to find all bricks named "Spawnpoint", and then making a random pick of one of the spawn bricks, and then teleporting the player to the brick.
Whenever I try to test the script in studio, I keep getting this error: attempt to get length of local 'v' (a userdata value) Any way I can fix this?

2 comments
is this a localscript or a serverscript?
May I ask how you make this into a format that is similar to what you get in studio on roblox. Btw 1st line i would do "for i,v in pairs(game.Workspace:GetChildren()) do"