basically what i want to know how to do is:
How do i make each player spawn in individual beds?
i cna do the rest but i need to know how to spawn them in order
so like plr 1 spawns in only bed 1 ect
Thanks!
2 Likes
Maybe something like:
local Players = game:GetService("Players")
local WS_Spawns = game:WaitForChild("Workspace"):WaitForChild("Spawns") -- your spawns folder
local WS_Spawns_Children = WS_Spawns:GetChilren()
local module = {}
function module.Teleport()
for _, player in pairs(Players:GetChildren()) do
if player.Character then
if player.Character:FindFirstChild("HumanoidRootPart") then
-- teleport and remove spawn from table
player.Character.HumanoidRootPart.CFrame = table.remove(WS_Spawns_Children, math.random(#WS_Spawns_Children)).CFrame -- + Vector3.new(0,+4,0)
else
warn("SERVER | TELEPORT | ERROR: HumanoidRootPart not found.", player)
end
else
warn("SERVER | TELEPORT | ERROR: Character not found.", player)
end
-- refresh spawns if they have all been used
if #WS_Spawns_Children == 0 then
WS_Spawns_Children = WS_Spawns:GetChildren()
end
end
end
return module
1 Like
have u tested this or do u already use it?
1 Like