OverheadGui level doesn't count up for other players

  1. My Goal is completing a waiting game while the players leveling up automatically.

  2. The problem is, which is shown in the picture, that both players level going up but they can check on other players level because it stays on 0.*

The next thing I am gonna show you is the script:

local Players = game:GetService("Players")

local rankInformation = require(script.Rankinformation)

local connections = {}
local overHeadTemplate = script.OverheadGui

Players.PlayerAdded:Connect(function(player)
	connections[player] = player.CharacterAdded:Connect(function(character)
		--while wait(0.01) do --Loop with Duplication Glitch but works!
		local newOverhead = overHeadTemplate:Clone()
		
		newOverhead.PlayerName.Text = player.Name
		newOverhead.Levels.Text = "Level: " ..player.leaderstats.Level.Value
		
		for _, info in pairs(rankInformation) do
			local isPlayerInDivision = player:IsInGroup(info.groupId)
			if isPlayerInDivision then		
				newOverhead.Group.Text = info.name
				newOverhead.Group.TextColor3 = info.color
				newOverhead.Group.Visible = true
				
				newOverhead.Rank.Text = player:GetRoleInGroup(info.groupId)
				newOverhead.Rank.Visible = true
				newOverhead.Rank.TextColor3 = Color3.fromRGB(136, 225, 20)
			end
		end
		
		character:WaitForChild("Humanoid").DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
			newOverhead.Parent = character:WaitForChild("HumanoidRootPart")
			--character.HumanoidRootPart.OverheadGui:Destroy() --Doesn't do anything Destroy's maybe everything but doesn't come back.
		--end --Loop with Duplication Glitch but works!	
	end)
end)

Players.PlayerRemoving:Connect(function(player)
	if connections[player] then
		connections[player]:Disconnect()
		connections[player] = nil
	end
end)

The script needs one line or maybe more to get the level shown to other players while playing!
3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

  1. In the script you can see I did add a wait() in one of the columns which I thought it’s a great idea but
    the OverheadText did not got Destroyed nor it helped. (So don’t use my idea!)

*Now here comes the interesting part:
After I played with the two players, I killed one (reset button) and then the level got renamed as the one on the leaderstats or the Value. (Where I usually count the level up).
The other player could see the new level but didn’t count further on.
The reset method is not an valid answer what I am looking for.

I want someone post a part script and tell me in which column I should put it in!
Thanks for reading :grin:

maybe you are changing the level text from local script?

The leveling up script is here:
Was already a local script. I hope that’s what you meant.

1 Like

If you are changing level text from local script others players won’t see level changing unless the server script changes it. Like it does when player resets

You are advicing me that the script should always recover inside the main script “OverheadGui script” but how would it be written?

I couldn’t insert a new variable for players level nor the wait() and loop thing except this position which is shown, it happens that I am at my programing limit.

I will now delete the local script, keep it somewhere save and now what? :neutral_face:

The wait() will duplicate but lags the server very fast and the part below will not work because it’s looping the first half of the script over and over.

Just add this inside ur main PlayerAdded function

player.leaderstats.Level.Changed:Connect(function()
	if player.Character and player.Character.Parent ~= nil and player.Character.HumanoidRootPart:FindFirstChild("OverheadGui") then
		player.Character.HumanoidRootPart.OverheadGui.Levels.Text = "Level: " ..player.leaderstats.Level.Value
	end
end)
1 Like

Thank you very much!
I had to change some names but it workes after play testing it,
now I can go copy the whole pack inside my original play area.

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