I’m attempting to make a game where it spawns you in a random room with different chances, like a basic room with a 1 in 2 chance to spawn into. Is there a way to script this? I’m not much of a scripter myself, tbh.
1 Like
Mabye a code like this
local rugs = game.Workspace:WaitForChild("Rugs"):GetChildren()
--workspace folder with rugs
local ServerStorage = game:GetService("ServerStorage")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local checkpoint = rugs[math.random(1,#rugs)]
local checkpointData = ServerStorage:FindFirstChild("CheckpointData")
if not checkpointData then
checkpointData = Instance.new("Folder")
checkpointData.Name = "CheckpointData"
checkpointData.Parent = ServerStorage
end
local userIdString = tostring(player.UserId)
local checkpointValue = checkpointData:FindFirstChild(userIdString)
if not checkpointValue then
checkpointValue = Instance.new("ObjectValue")
checkpointValue.Name = userIdString
checkpointValue.Parent = checkpointData
player.CharacterAdded:connect(function(character)
wait()
local storedCheckpoint = ServerStorage.CheckpointData[userIdString].Value
character:MoveTo(storedCheckpoint.Position + Vector3.new(math.random(-4, 4), 4, math.random(-4, 4)))
end)
end
checkpointValue.Value = checkpoint
end)
end)
how can i create more values for more spawnpoints e.g. 1 in 8, 1 in 26, etc.
add more rugs to the rug folder at the top of the code