Making a ranking system

Hello. I am currently making a game that involves people getting first, second, or third. Currently, I have it when the first person touches the finishing platform, it sets a winning value to their name. But, I want to make it so that when another person touches the platform (the one who got second) sets the secondplace value to their name and same thing for when the third person touches the platform. Here is my script so far:

script.Parent.Touched:Connect(function(hit)
	
	local hum = hit.Parent:FindFirstChild("Humanoid")
		
		game.ReplicatedStorage.Values.WinnerValue.Value = hit.Parent.Name
		game.ReplicatedStorage.Values.WinnerValue.Value = game.StarterGui.WinningScreen.Frame.firstname.Text

end)

Do not mind the script involving the GUI. The values I have are located in Replicated Storage in a folder called β€œValues.” The values are called WinnerValue, SecondPlace, and ThirdPlace. Thank you for reading! If I didn’t explain anything correctly or if something needs an explanation, please ask.

5 Likes

Maybe something like this

if game.ReplicatedStorage.Values.WinnerValue.Value == nil  then-- checks if no one has hit the finish line
      game.ReplicatedStorage.Values.WinnerValue.Value == hit.Parent.Name
elseif game.ReplicatedStorage.Values.SecondWinnerValue.Value == nil  then--checks if any second person has hit the end
      game.ReplicatedStorage.Values.SecondWinnerValue.Value = hit.Parent.Name
elseif game.ReplicatedStorage.Values.ThirdWinnerValue.Value == nil then
game.ReplicatedStorage.Values.ThirdWinnerValue.Value 
end

This just bassically goes from first to thrid, if a player finishes and someone has already finished they will be saved as second place. though if someone touches the finish twice, it will cause them to possibly be in first and second or second and thrid, this can just be solved by checking if the player hasn’t already been saved into a value

2 Likes

I changed my script to this:

script.Parent.Touched:Connect(function(hit)
	
	local hum = hit.Parent:FindFirstChild("Humanoid")
		
	if game.ReplicatedStorage.Values.WinnerValue.Value == nil  then-- checks if no one has hit the finish line
		game.ReplicatedStorage.Values.WinnerValue.Value = hit.Parent.Name
	elseif game.ReplicatedStorage.Values.SecondPlace.Value == nil  then--checks if any second person has hit the end
		game.ReplicatedStorage.Values.SecondPlace.Value = hit.Parent.Name
	elseif game.ReplicatedStorage.Values.ThirdPlace.Value == nil then
		game.ReplicatedStorage.Values.ThirdPlace.Value = hit.Parent.Name
		
		
	
	end
end)

I made all the necessary changes to fit the variable names and fixed the extra β€˜=’ in the 2nd and fourth line of your script but it does not seem to be working. There are no errors noted in the output so I do not know what is wrong.

1 Like

Try this:

--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--//Variables
local Part = script.Parent

--//Functions
Part.Touched:Connect(function(hit)
	local Humanoid = hit.Parent:FindFirstChild("Humanoid")
	
	if Humanoid then
		if ReplicatedStorage.Values.WinnerValue.Value == nil  then
			ReplicatedStorage.Values.WinnerValue.Value = hit.Parent.Name
			
		elseif ReplicatedStorage.Values.SecondPlace.Value == nil  then
			ReplicatedStorage.Values.SecondPlace.Value = hit.Parent.Name
			
		elseif ReplicatedStorage.Values.ThirdPlace.Value == nil then
			ReplicatedStorage.Values.ThirdPlace.Value = hit.Parent.Name
		end
	end
end)
1 Like

Weird. This script doesn’t seem to work either. I made a clean baseplate with a part and three values in a folder called β€œValues” located in ReplicatedStorage but the script doesn’t work there either.

What values are they? Boolvalues, stringvalues, objectvalues, etc?

The values are string values. char

β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž β€Žβ€Žβ€Ž

Try this bro:

script.Parent.Touched:Connect(function(hit)
	
	local hum = hit.Parent:FindFirstChild("Humanoid")
	if hum then
        if game.ReplicatedStorage.Values.WinnerValue.Value == nil  then-- checks if no one has hit the finish line
			game.ReplicatedStorage.Values.WinnerValue.Value = hit.Parent.Name
		elseif game.ReplicatedStorage.Values.SecondPlace.Value == nil  then--checks if any second person has hit the end
			game.ReplicatedStorage.Values.SecondPlace.Value = hit.Parent.Name
		elseif game.ReplicatedStorage.Values.ThirdPlace.Value == nil then
			game.ReplicatedStorage.Values.ThirdPlace.Value = hit.Parent.Name
		end
    end
end)

Also you should show me the scripts for the GUI so I can fix your problem if the above code doesn’t work. If it worked it please set it as the solution :smiley: Thanks!

This script does not work either and I am using a brandnew baseplate to make sure their are no outside processes affecting it. I don’t seem to know why it is not working. So basically what I am trying to do, is when the 1st, 2nd, 3rd person touch the platform, their names go to the specific values. Those values are then used after the round is over to show who won on a GUI by the values being linked to a label.

So really, im trying to get the values = to what place each person got so it can be shown on the GUI. If you need any more explanation, just ask.

Ok, but did you check it from the server or the client?

Client because I would not be able to see if the values changed on a server without something to show in the output.

Just tested it in a server and it does not work there either.

what do you mean β€œtested in the server” ? Because you are using a server script to change the value so you should look at the value rom the server side

I have been looking at the value in Studio using the explorer and keeping the properties of the value open. I misworded the last thing I said. Regardless, the value is not changing and there are no errors shown in the output.

Try this bro:

script.Parent.Touched:Connect(function(hit)
	
	local hum = hit.Parent:FindFirstChild("Humanoid")
	if hum then
        if game.ReplicatedStorage.Values.WinnerValue.Value == nil  then-- checks if no one has hit the finish line
			game.ReplicatedStorage.Values.WinnerValue.Value = hit.Parent.Name
            print("A")
		elseif game.ReplicatedStorage.Values.SecondPlace.Value == nil  then--checks if any second person has hit the end
			game.ReplicatedStorage.Values.SecondPlace.Value = hit.Parent.Name
            print("B")
		elseif game.ReplicatedStorage.Values.ThirdPlace.Value == nil then
			game.ReplicatedStorage.Values.ThirdPlace.Value = hit.Parent.Name
            print("C")
		end
    end
end)

Tell me what does it print

It did not print anything in the output. I don’t think I am doing anything wrong since I am testing this in a clean baseplate.

OOOOOH i get it now what is the script.Parent of the script??

This is the code, and the benefit to this is that you can get everyone’s rank, so I think this is just better.

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 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)
1 Like

The part you touch that activates the function.