Hi, i made a script where all the players get a ui where the round will start in 15 seconds, after the 15 seconds they get teleported to a place where they will have to do a obby, but it only shows the ui to 1 player and teleports only that player.
here is my code:
local tpall = game.Workspace:WaitForChild("TeleportAll")
local Grow = game.Workspace.Grow -- Assuming the script is a child of the "Grow" part
local originalSize = Vector3.new(7.028, 156.945, 135.364)
local targetSize = Vector3.new(82.476, 156.945, 135.364)
local growthRate = Vector3.new(0.03, 0, 0)
local positionChange = Vector3.new(0, 0.015, 0)
local playercount = 0
local playerCharacters = {}
local textchange = game.ReplicatedStorage:WaitForChild("TextChanger")
game.Players.PlayerAdded:Connect(function(plr)
playercount = playercount + 1
print('player added')
local text = plr:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("TextLabel")
while task.wait(1) do
if playercount >= 1 then
print("Enough players.")
for i, player1 in pairs(game.Players:GetPlayers()) do
local character = player1.Character or player1.CharacterAdded:Wait()
if player1.PlayerGui.ScreenGui.Enabled == false then -- access playerGui through player
player1.PlayerGui.ScreenGui.Enabled = true
textchange:FireClient(player1, "ScreenGui", "TextLabel", "Round starting in 15 seconds.") -- only fire client to player with ScreenGui disabled
wait(15)
player1.PlayerGui.ScreenGui.Enabled = false
character:MoveTo(game.Workspace.TeleportAll.Position) ---- here is the problem
wait(1)
while true do
wait(0.01)
local currentSize = Grow.Size
local newSize = currentSize + growthRate
local newPosition = Grow.Position + positionChange
if currentSize.magnitude < targetSize.magnitude then
if newSize.magnitude > targetSize.magnitude then
newSize = targetSize
end
Grow.Size = newSize
Grow.Position = newPosition
else
Grow.Size = originalSize
Grow.Position = Vector3.new(718.122, -13.29, 95.35)
for i, player1 in pairs(game.Players:GetPlayers()) do
local character = player1.Character or player1.CharacterAdded:Wait()
character:MoveTo(game.Workspace.Spawn.Position)
break
end
end
print('not starting')
if playercount <= 1 then
wait(3)
for i, player1 in pairs(game.Players:GetPlayers()) do
if player1.PlayerGui.ScreenGui.Enabled == false then
player1.PlayerGui.ScreenGui.Enabled = true
print("UI enabled.")
textchange:FireClient(player1, "ScreenGui", "TextLabel", "Not enough players.")
wait(5)
player1.PlayerGui.ScreenGui.Enabled = false
end
end
end
end
end
end
end
end
end)
game.Players.PlayerRemoving:Connect(function()
playercount = playercount - 1
print('player removed')
end)