Hey! It works! Thank you so much. I set your response as the solution.
Do you mind helping me with one more other thing too? I want to make sure that it isnât making the values all one person which is what it is doing now. Could you add something to the original script you made to make sure that if it that person already has a place as a 1st, 2nd, or 3rd spot it will not set the other values to the same player?
I donât think I am understanding this correctly, you donât want the same player to get the 1st, 2nd, and 3rd twice in a row?
Ohh, I think I understand now, you donât want the same person touching the FinishPart over and over again to fill up the list right?
Yeah, that is what I was thinking of.
Sorry for the late response, but this is the code
local Values = game.ReplicatedStorage:WaitForChild("Values");
local FinishedPlayers = {}; --All the players who touched the FinishPart will be added to this list in order.
FinishPart.Touched:Connect(function(Hit)
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent); --Get the player.
if Player --[[New code here]]and not table.find(FinishedPlayers, Player)--[[New code here]] then --If the player exist then continue.
local Rank = (#FinishedPlayers + 1); --Get the rank.
FinishedPlayers[Rank] = Player; --Add the player to the list.
if Rank == 1 then
Values.FirstPlace.Value = Player.Name; --Or Player.DisplayName;
elseif Rank == 2 then
Values.SecondPlace.Value = Player.Name; --Or Player.DisplayName;
elseif Rank == 3 then
Values.ThirdPlace.Value = Player.Name; --Or Player.DisplayName;
end
end
end)
and not table.find(FinishedPlayers, Player)
this checks if the player is in the âFinishedPlayersâ list
Thank you man. I appreciate it so much.
Hey. I know you might not see this but there is an issue with the script. I am making a game that involves players trying to be the first to touch the finish part. The problem is, because of the finishing players part of the code, it is only allowing the value to be changed once for that player. What I am saying is, if a player wins one round and then the next round they win again, it will not change the value to that players name because he/she is part of the FinishedPlayers list. Do you know anyway that will fix this?
Easy! Evey time you start a new round, just clear the FinishedPlayers, you can do this by the following
--Recommended
table.clear(FinishedPlayers);
FinishedPlayers = {};
for _, v in pairs(FinishedPlayers) do
v = nil;
end