Keep the highest number Tag

Guys, I’m still trying to figure out how to make my game detect the player with least progress in the obby map of the round, and eliminate them, and I had the idea of adding tags to the player for each part they step on.

If a map has 7 parts, I put 1 script in each part like this (script for Part2):

local cs = game:GetService(“CollectionService”)

script.Parent.Touched:Connect(function(part)
if part.Parent:FindFirstChild(“Humanoid”) then
cs:AddTag(part.Parent, “2”)
end
end)

For Part3 i add the tag with number 3 etc

But now i need to know how to make it so that when the player is on Part5 and falls, and then steps on Part1 again, their tag keeps being the number 5, not 1.

Can someone help? By the way I’m very noob at scripting I don’t know exactly how tags work I’m just trying

On the code under the Touched event for part1. Make an if statement to check if the players current tag is more than 1 or not.

If its more than 1 then dont set the players tag.

1 Like

I wrote

local cs = game:GetService(“CollectionService”)

script.Parent.Touched:Connect(function(part)
if part.Parent:FindFirstChild(“Humanoid”) and not part.Parent.Tag >1 then
cs:AddTag(part.Parent, “1”)
end
end)

I can’t test it though, do you know if it’s right?

You would need to test it to make sure. But, Im pretty sure that would work fine.

1 Like

Ok thank you for the help XD
I think it might work