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

Why does this script not change the player's team?

I have a script here:

player = game.Players.LocalPlayer

while true do
	if player.Teams == "Eliminating" then
		while true do
			if player.Character:FindFirstChild("Humanoid").Health == 0 then
				player.Teams = "Lobby"
			end
		end
	end
end

But, when I run it, it does not affect the player's team.

1 answer

First of all when ever you're gonna do

while true do end

You need to add this

wait()

Or else it'll overload your game. Also have you ran it on a localscript? Also you do not need 2 while true do's All you need is one since that will loop until false anyways here's the fixed code

This is an Edit!!

player = game.Players.LocalPlayer

while true do
    if player.Teams == game.Teams.Eliminating then
            if player.Character:FindFirstChild("Humanoid").Health == 0 then
                player.Teams = game.Teams.Lobby
        end
    end
wait()
end

Also after running this code you have to reset your character in order to be placed into the "Lobby" team

2 comments

0

I tried this, and i used a local server, rested, but it still does not work

0

I fixed it it's because Team points to an object instead of a string value

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