Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you make a script that teleports all players when an a text label reaches "0"?

this is the script i used in serverScriptService

local rl = 5
local il = 5
local InRound = game.ReplicatedStorage.InRound
local Lobby = game.Workspace.LobbySpawn
local gameArea = game.Workspace.GameSpawn
local status = game.ReplicatedStorage.Status

local success = InRound.Changed:Connect(function()
	wait(1)
	if InRound.Value == true then
		for _, player in pairs(game.Players:GetChildren())do
				local char = player.Character
				char.Humanoid.Position = gameArea.Position
			end
		else
			for _, player in pairs(game.Players:GetChildren())do
				local char = player.Character
				char.Humanoid.Position = Lobby.Position
			end
		end
end)


local function intermission()
	while wait do
		for i = il, 1, -1 do
			InRound.Value = false
			wait(1)
			status.Value = "Game Starting In: ".. i
			end
			for i = rl, 1, -1 do
				InRound.Value = true
				wait(1)
				status.Value = "Game: "..i
			end
		end
	end
	
	spawn(intermission)

this is the local script i used in the starter Gui

local status = game.ReplicatedStorage.Status
local tl = script.Parent.TextLabel

status.Changed:Connect(function()
	tl.Text = status.Value
end)

1 comment

0

I used the print command to see if there was a problem and there was one. But i dont know where.

1 answer

✓ Accepted answer

I think the error is at line 12 because character isn't defined properly please do the following code Make sure this is in starterplayerscripts :

game.Players.PlayerAdded:Connect(function(plr)
local player = game.Players.LocalPlayer
local character = player.Character
local rl = 5
local il = 5
local InRound = game.ReplicatedStorage.InRound
local Lobby = game.Workspace.LobbySpawn
local gameArea = game.Workspace.GameSpawn
local status = game.ReplicatedStorage.Status

local success = InRound.Changed:Connect(function()
    wait(1)
    if InRound.Value == true then
        for _, player in pairs(game.Players:GetChildren())do
                local char = player.Character
                char.Humanoid.Position = gameArea.Position
            end
        else
            for _, player in pairs(game.Players:GetChildren())do
                local char = player.Character
                char.Humanoid.Position = Lobby.Position
            end
        end
end)


local function intermission()
    while wait do
        for i = il, 1, -1 do
            InRound.Value = false
            wait(1)
            status.Value = "Game Starting In: ".. i
            end
            for i = rl, 1, -1 do
                InRound.Value = true
                wait(1)
                status.Value = "Game: "..i
            end
        end
    end

    spawn(intermission)


end
end)

3 comments

0

Oh thats true thanks, if it still doesnt work idc since someone helped me with one of my probles :)

0

It doesnt work in player scripts.

0

It should work also try startercharacter.

This discussion is preserved as it was. New answers, comments, and votes are closed.