Can anyone help me find the issue in this script?

I own a racing server on roblox, and we use Wesley1041’s Race Standings Script (can be found on RoRacing.com if you’re interested to know where its from officially. It was previously linked on his profile, However not anymore.) This helps us track which player is in a specific position, whether they are first or last. However I’ve recently stumbled across a long-lasting issue with a change I made. Whenever a person is counted, they are for some reason overlapping above first place, this happens every time a position is changed. See the clips below for the issue. Ive also copied the part of the script which should be displaying the names of users and their positions and stuff


local function Update(order, save)
	if order.Parent.Mode.Value == "Race" then
		for _, item in pairs(order:GetChildren()) do
			local pos = 1
			local it = frame.Display:FindFirstChild(item.Name)
			if it == nil then
				it = frame.LapTemplate:Clone()
				it.Name = item.Name
				it.Parent = frame.Display
				it.Visible = true
				it.Size = UDim2.new(1, 0, 0.039, 0)

				local carName = getCarNameForPlayer(game:GetService("Players"):FindFirstChild(item.Name))

				if carName then
					local teamCode = extractTeamFromCarName(carName)

					if teamToColor[teamCode] then
						it.teamicon.BackgroundColor3 = teamToColor[teamCode]
						savedData[item.Name] = { Color = teamToColor[teamCode], Abbr = it.Driver.Text }
					else
						it.teamicon.BackgroundColor3 = Color3.new(0, 0, 0)
					end
				else
					it.teamicon.BackgroundColor3 = Color3.new(0, 0, 0)
				end

				if usernameAbbr[item.Name] then
					it.Driver.Text = usernameAbbr[item.Name]
				else
					it.Driver.Text = string.upper(string.sub(item.Name, 1, 3))
				end
			end

			it.Gap.BackgroundTransparency = 1
			for _, other in pairs(order:GetChildren()) do
				if other ~= item and (other.Laps.Value > item.Laps.Value or (other.Laps.Value == item.Laps.Value and other.Sector.Value > item.Sector.Value) or (other.Laps.Value == item.Laps.Value and other.Sector.Value == item.Sector.Value and other.Elapsed.Value < item.Elapsed.Value)) then
					pos += 1
				end
			end

			it.Place.Value = pos
			it.Pos.Text = pos

			if pos == 1 then
				leader = item
				raceEvent:FireServer(item.Laps.Value + 1)
				it.Gap.Text = "Leader"
			else
				local gap = item.Gap.Value - leader.Gap.Value
				it.Gap.Text = "+--.---"
			end
		end

		for _, other in pairs(order:GetChildren()) do
			if other ~= leader then
				local ot = frame.Display:FindFirstChild(other.Name)
				if other.Laps.Value == leader.Laps.Value then
					local gap = other.Gap.Value - leader.Gap.Value
					ot.Gap.Text = "+" .. ConvertTime(gap)
				elseif other.Laps.Value < leader.Laps.Value and other.Gap.Value > leader.Gap.Value then
					local laps = leader.Laps.Value - other.Laps.Value
					ot.Gap.Text = "+" .. laps .. " Laps"
				end
			end
		end
	else
		for _, item in pairs(frame.Display:GetChildren()) do
			item:Destroy()
		end
	end
end

It is quite messy, So I do apologise if its a bit much. but if anyone can help me find the issue, that would be great. Thanks!

also do let me know if ive put the wrong tags or not because this is literally my first post here :pray:

2 Likes

Maybe

it.Place.Value = pos
it.Pos.Text = pos
it.LayoutOrder = pos

I’ve only had a quick look, sorry I just saw my work shift is starting soon, but I am thinking perhaps the display should come later as it seems to show before it is in the right place.

Use LayoutOrder so the leaderboard shows players in the correct order. Without it, the UI just overlaps

1 Like

I agree and that may be the problem at the moment…

So I did that and it still didnt quite work out well :sob:


Am I just missing something here??

If it wasn’t that then idk… maybe the lack of uilistlayout is making it overlap but if after the addition of uilistlayout it still doesn’t work then you should probably just leave it

I tried this but it didn’t fix anything :man_shrugging:

1 Like

This is one you need to have to look at it… They are all stacking up on the same spot. Where in your script are you working with that placement. Take a long look at that.

I may have found the problem, I believe I accidentally removed tweenservice lines which caused this to happen. I’ll experiment during the next few hours to see if that’s what it is.

Yeah so I got an alt account to test this, it was tweenservice. we’re good now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.