How do I fix this percentage script?

The place file I uploaded works fine, make sure you are changing it from the server and not the client.


image

TL;DR
Use a localscript instead
Don’t use PlayerAdded

tho only to the local player will it look correct so does it do the math on the client and tell the server to change it?

I don’t know what you are talking about, here is the script I used in the place file. It is changing the percentage from the server so all players can see it.

--\\ Variables //--
local GamePlayers = game:GetService("Players")
local GroupId = script.Configuration.GroupId
local RankId = script.Configuration.RankId


--\\ Configuration //--
game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local CloneTag = script.NameTag:Clone()
		local Name = Player.Name
		
		
		--// Config \\--
		CloneTag.Parent = Character.Head
		CloneTag.Primary.Text = Player:GetRoleInGroup(GroupId.Value)
		local leaderstats = Player:WaitForChild("leaderstats")
		local RankService = Player:WaitForChild("RankService")
		local MaxProgression = RankService:WaitForChild("MaxProgression")
		local Progress = leaderstats:WaitForChild("Progress")
		Progress:GetPropertyChangedSignal("Value"):Connect(function()
			CloneTag.Secondary.Text = math.floor((Progress.Value/MaxProgression.Value)*100).."%"
		end)
	end)
end)

Seems like it’s working as on client!
Thank you both for helping me out, I appreciate it! :wink:

  1. Cloned instances ALWAYS have child loaded, no need to waitforchild
  2. ValueBase.Changed is a modified version, no need to use GetPropertyChangedSignal
  3. This will cause memory leak if the player died since the connection isn’t cleaned, and it will be connected multiple times after the player died, to something parented to nil.
1 Like
--\\ Variables //--
local GamePlayers = game:GetService("Players")
local GroupId = script.Configuration.GroupId
local RankId = script.Configuration.RankId


--\\ Configuration //--
game.Players.PlayerAdded:Connect(function(Player)
	local LastConnection = nil
	
	
	Player.CharacterAdded:Connect(function(Character)
		local CloneTag = script.NameTag:Clone()
		local Name = Player.Name
		
		
		--// Config \\--
		CloneTag.Parent = Character.Head
		CloneTag.Primary.Text = Player:GetRoleInGroup(GroupId.Value)
		local leaderstats = Player:WaitForChild("leaderstats")
		local RankService = Player:WaitForChild("RankService")
		local MaxProgression = RankService.MaxProgression
		local Progress = leaderstats.Progress
		if LastConnection ~= nil then LastConnection:Disconnect() end
		LastConnection = Progress.Changed:Connect(function()
			CloneTag.Secondary.Text = math.floor((Progress.Value/MaxProgression.Value)*100).."%"
		end)
	end)
end)
1 Like