Elimination issue + teleport issue

Ok I will try it now then I come back to tell what happened.

Ok, now no one was teleported ;-;

It said there is an error in line 6 because Character is not a part of workspace.Laverr54

oh I get the error xD you should replace it with this:

script.Parent.Touched:Connect(function(hit)
   local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
    if plr then
       hit.Parent.HumanoidRootPart.CFrame = RandomLobbySpawn.CFrame
-- I pretty sure that if you replace hit.Parent.HumanoidRootPart with just "hit"
--it will work too but idk
    end
end)
1 Like

Oh thank you! Now only who touches the teleporter gets teleported (:

But still player B is always the eliminated one even when he wins… I think there is something wrong with “slowestPlayer” do you know how to correct that?

I think you meant hit.parent.Stage.Value < stageNumber
You also don’t have a default value for Stage.

1 Like

Bruh i just realised its not working yet. I thought it was :frowning:

Try spamming prints in the script like print(lowestStage .. slowestPlayer), print(player .. stage) and testing them in game. Does it still only eliminate player B?

Also why is this a for loop:

for _, Player in pairs(Players:GetChildren()) do
    slowestPlayer.Team = Spectators
end
1 Like

Now I think it is choosing a random player to eliminate everytime, I think it is choosing the “slowest player” in the beginning so its random, sometimes player A is eliminated now…

And i don’t know why i wrote for _, I was just trying to write it and that’s how i did it, What is the right way to write it?

there is no “right” way to type it.
_ is what you chose to write. _, in that case, means the current loop number in the loop
if you put “i” it will still have the same meaning but just a different way to call it

local module = {"hey", 2, true}

for i, v in pairs(module) do
     print(i)
end
print("finished loop 1")
-- it will do the same things as the other loops below

wait(2)

for _, v in pairs(module) do
     print(_)
end
print("finished loop 2")

wait(2)

for loopNumber, v in pairs(module) do
     print(loopNumber)
end
print("finished loop 3")

hope you get that, if you don’t just tell me what you don’t understand

1 Like

oh…I forgot that _ is a placeHolder. _ is the only thing that is different then the other names and means
that you will not call that in the loop

1 Like

So now i changed that part to:

slowestPlayer.Team = Spectators

And in the 1st round it eliminates the player with least progress, but then in the other rounds, it keeps eliminating the one eliminated in the first round (almost all of the times) I have no idea why…

I’m so frustrated

Try this

for _, player in pairs(Players:GetPlayers()) do
    if player.Team == Spectators then continue end -- don't check the spectators

	local char = player.Character
	if not char then continue end
	
	local stage = char.Stage.Value
	if stage < lowestStage then
		lowestStage = stage
		slowestPlayer = player
	end
end

slowestPlayer.Team = Spectators
slowestPlayer.Character.Stage.Value = math.huge -- change to whatever your default value is

Hey! I realised what the problem was… It was because the players’ stage wasn’t reseted for the new map, I discovered that putting print(1), print(3) etc in the checkpoints, the new round would begin and the number stayed high and wouldn’t go back to 0, so that’s why…

Do you know how to make the stage number be reseted?

I think I need to write something with “for _, Player in pairs” in the end of the script before the chosen map is destroyed.

Did you set a default value for Stage before the map is chosen

for _, Player in pairs(Players:GetChildren())do
	Player.Team = Contestants
    -- Player.Character.Stage.Value = 0, nil, math.huge, etc.
end

What do you mean? Um I think the default value should be 0, but I didn’t write that… The whole IntValue thing was written by other person and I am still confused how it works, without having something like:

local Stage = ???

I wrote in the end:

for _, Player in pairs(Players:GetChildren())do
for _, player in pairs(Players:GetPlayers()) do
local char = player.Character
if not char then continue end

	local stage = char.Stage.Value
	Player.Stage = 0
	end
end

And there was an error in the output, saying that Stage is not a valid member of Player “Players.Laverr54”

And there was an error in the output, saying that Stage is not a valid member of Player “Players.Laverr54”

so I get what is the error, the error is that char it isn’t the character because if it was char it was gonna
tell you Stage is not a valid member of Player “workspace.Laverr54”

so what you need to do is just do Player.Character

I think so. if not then do what @DaringAwesomeSauce said

1 Like

An IntValue is an instance that contains an integer value.

You can get the value of Stage by doing Stage.Value. In your script you parented it to each player’s character.

Player.Character.Stage.Value = 0

By doing local stage = char.Stage.Value and changing the value of stage, you are only copying the value and changing the copy, not the actual value.

1 Like

Wow thank you so much! It finally works! I thought it was never going to work I’m so happy really thanks for the patience XD

1 Like

Thanks bro you helped me a lot XD

@Laverr54 that’s why I’m here on the forum mostly, to help peoples :slight_smile:

1 Like