So what I have a problem with is that the script works half of the time. The Experience Points resets after a game is finished. But when people are waiting, usually one person that has low XP, and the person that has the second highest XP goes and gets teleported. I would like it for the people that always have the highest XP, are able to start the game.
function start(hit) --------------------------------------------------------------- Action from touching brick
local numb = game.Players.NumPlayers
cleanup()
if numb>1 then -- Check that there is more than 1 player
local person=hit.Parent
if person and person:findFirstChild("Humanoid") then
script.Disabled=true
local list = game.Players:GetPlayers()
local p1 = list[1]
local indy = 1
local p2 = list[2]
if numb > 2 then -- If players>=3 need to compare
for x = 2, #list do -- find player with highest exp
local numba = list[x].leaderstats.Experience.Value
if numba>list[x-1].leaderstats.Experience.Value then
p1 = list[x]
indy = x
end
end
table.remove(list, indy)
p2 = list[1]
for x = 2, #list do -- find player with second highest exp
local numba = list[x].leaderstats.Experience.Value
if numba>list[x-1].leaderstats.Experience.Value then
p2 = list[x]
end
end
end
Competition(p1,p2) -- Initializes positions and gets rid of their balls
runclock(gametime) -- Other script waits for shotclock to start
finish()
script.Disabled=false
else
wait()
end
end
end
brick.Touched:connect(start)

4 comments
I can read your code, but I can't read your mind. If you don't tell me what the code is SUPPOSED TO do, I don't know where you went wrong. Please describe the intended functionality
Also, when you post code with a bunch of Values, it helps to post a screenshot
And if you post code with a bunch of functions that we can't see defined, we have no clue what is happening in those places
Oh I've got this figured out lol