You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to teleport players to a spawn thats not already been used by another player. -
What is the issue? Include screenshots / videos if possible!
Sometimes (in both studio and real game) one player spawns below the map. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried many solutions (see my script below)
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
for i, plr in pairs(game.Players:GetPlayers()) do
if plr:WaitForChild("Playing").Value == true then
local SameMatch = Instance.new("BoolValue")
SameMatch.Parent = plr
SameMatch.Name = "SameMatch"
plr:WaitForChild("Matches").Value = plr:WaitForChild("Matches").Value + 1
plr.CameraMinZoomDistance = 0.5
plr.CameraMaxZoomDistance = 0.5
plr.CameraMode = Enum.CameraMode.LockFirstPerson
plr.Character.Humanoid.MaxHealth = plr.Stats.Health.Value
wait()
plr.Character.Humanoid.Health = plr.Stats.Health.Value
local Character = plr.Character
if Character:FindFirstChild("HumanoidRootPart") then
plr.Character.Humanoid.WalkSpeed = plr.Stats.WalkSpeed.Value
plr.Character.Humanoid.JumpPower = plr.Stats.JumpPower.Value
local Rand = Random.new()
local Spawns = game.Workspace.Map.Spawns:GetChildren()
local ChosenSpawn = Spawns[Rand:NextInteger(1, #Spawns)]
if ChosenSpawn.Enabled == false then
ChosenSpawn.Enabled = true
print(ChosenSpawn.Position)
print("Spawn found in first try")
--wait()
plr.Character:SetPrimaryPartCFrame(CFrame.new(ChosenSpawn.Position + Vector3.new(0, 10, 0)))
--plr.Character.HumanoidRootPart.CFrame = ChosenSpawn.CFrame + Vector3.new(0,10,0)
--wait(1)
--plr.Character.HumanoidRootPart.CFrame = ChosenSpawn.CFrame + Vector3.new(0,10,0)
elseif ChosenSpawn.Enabled == true then
local Found = false
repeat
AlternativeSpawn = Spawns[Rand:NextInteger(1, #Spawns)]
print("Searching for alternative spawn")
if AlternativeSpawn.Enabled == false then
AlternativeSpawn.Enabled = true
print("Alternative spawn found")
Found = true
--wait()
plr.Character:SetPrimaryPartCFrame(CFrame.new(AlternativeSpawn.Position + Vector3.new(0, 10, 0)))
--plr.Character.HumanoidRootPart.CFrame = AlternativeSpawn.CFrame + Vector3.new(0,10,0)
--wait(1)
--plr.Character.HumanoidRootPart.CFrame = ChosenSpawn.CFrame + Vector3.new(0,10,0)
end
until Found == true
end
elseif not Character:FindFirstChild("HumanoidRootPart") then
repeat wait()
until Character:FindFirstChild("HumanoidRootPart")
plr.Character.Humanoid.WalkSpeed = plr.Stats.WalkSpeed.Value
plr.Character.Humanoid.JumpPower = plr.Stats.JumpPower.Value
local Rand = Random.new()
local Spawns = game.Workspace.Map.Spawns:GetChildren()
local ChosenSpawn = Spawns[Rand:NextInteger(1, #Spawns)]
if ChosenSpawn.Enabled == false then
print("Found spawn in first try")
print(ChosenSpawn.Position)
ChosenSpawn.Enabled = true
--wait()
plr.Character:SetPrimaryPartCFrame(CFrame.new(ChosenSpawn.Position + Vector3.new(0, 10, 0)))
--plr.Character.HumanoidRootPart.CFrame = ChosenSpawn.CFrame + Vector3.new(0,10,0)
--wait(1)
--plr.Character.HumanoidRootPart.CFrame = ChosenSpawn.CFrame + Vector3.new(0,10,0)
elseif ChosenSpawn.Enabled == true then
local Found = false
repeat
AlternativeSpawn = Spawns[Rand:NextInteger(1, #Spawns)]
print("Searching for alternative spawn")
if AlternativeSpawn.Enabled == false then
AlternativeSpawn.Enabled = true
print("Alternative Spawn Found")
Found = true
--wait()
plr.Character:SetPrimaryPartCFrame(CFrame.new(AlternativeSpawn.Position + Vector3.new(0, 10, 0)))
--plr.Character.HumanoidRootPart.CFrame = ChosenSpawn.CFrame + Vector3.new(0,10,0)
--wait(1)
--plr.Character.HumanoidRootPart.CFrame = ChosenSpawn.CFrame + Vector3.new(0,10,0)
end
until Found == true
end
end
end
wait()
end
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.