local ServerStorage = game:GetService("ServerStorage")
local statUnder = ServerStorage:WaitForChild("statUnder")
local abbreviations = {
"",
"K",
"M",
"B",
"T"
}
local function abbreviateNumbers(Number)
for i = 1, #abbreviations do
if Number < 10 ^ (i * 3) then
if abbreviations[i] == "∞" then
return "∞"
else
return math.floor(Number / ((10 ^ ((i - 1) * 3)) / 100)) / (100) .. abbreviations[i]
end
elseif tostring(Number) == "Inf" then
return "∞"
end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local Head = character:WaitForChild("Head")
local ld = player:WaitForChild("leaderstats")
repeat task.wait(0.35) until character:FindFirstChild("Head")
Head = character.Head
local uiClone = statUnder:Clone()
uiClone.Name = "StatUnderClone"
uiClone.Parent = Head
local uiClone2 = ServerStorage:WaitForChild("rebirthUnder")
uiClone2.Name = "RebirthUnderClone"
uiClone2.Parent = Head
local function update()
uiClone.stat.Text = abbreviateNumbers(player.leaderstats.Power.Value + ld.Mass.Value).. " Power"
print("update Power")
end
local function updateRebirth()
if player.leaderstats.Rebirth.Value == 0 then
uiClone2.stat2.Text = "🤓Noob"
print(uiClone2.stat2.Text)
elseif player.leaderstats.Rebirth.Value == 1 then
uiClone2.stat2.Text = "😑Beginner"
print(uiClone2.stat2.Text)
elseif player.leaderstats.Rebirth.Value == 2 then
uiClone2.stat2.Text = "🙂Rookie"
print(uiClone2.stat2.Text)
elseif player.leaderstats.Rebirth.Value == 3 then
uiClone2.stat2.Text = "🔰Novice"
elseif player.leaderstats.Rebirth.Value == 4 then
uiClone2.stat2.Text = "🧑🎓 Learner"
elseif player.leaderstats.Rebirth.Value == 5 then
uiClone2.stat2.Text = "🎓Trainee"
elseif player.leaderstats.Rebirth.Value == 6 then
uiClone2.stat2.Text = "👩🏻💻Apprentice"
elseif player.leaderstats.Rebirth.Value == 7 then
uiClone2.stat2.Text = "🥊Amateur"
elseif player.leaderstats.Rebirth.Value == 8 then
uiClone2.stat2.Text = "🚆Intermediate"
end
end
update()
wait(1)
updateRebirth()
player.leaderstats.Power:GetPropertyChangedSignal("Value"):Connect(update)
player.leaderstats.Mass:GetPropertyChangedSignal("Value"):Connect(update)
player.leaderstats.Rebirth:GetPropertyChangedSignal("Value"):Connect(updateRebirth)
character.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
end)
end)
So this is my script for showing the player’s strength over the player’s head, but when the strength is increased, the strength over the head is not updated, and print is not displayed. Why? Т
local ServerStorage = game:GetService("ServerStorage")
local statUnder = ServerStorage:WaitForChild("statUnder")
local abbreviations = {
"",
"K",
"M",
"B",
"T"
}
local function abbreviateNumbers(Number)
for i = 1, #abbreviations do
if Number < 10 ^ (i * 3) then
if abbreviations[i] == "∞" then
return "∞"
else
return math.floor(Number / ((10 ^ ((i - 1) * 3)) / 100)) / (100) .. abbreviations[i]
end
elseif tostring(Number) == "Inf" then
return "∞"
end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local Head = character:WaitForChild("Head")
local ld = player:WaitForChild("leaderstats")
repeat task.wait(0.35) until character:FindFirstChild("Head")
Head = character.Head
local uiClone = statUnder:Clone()
uiClone.Name = "StatUnderClone"
uiClone.Parent = Head
local uiClone2 = ServerStorage:WaitForChild("rebirthUnder")
uiClone2.Name = "RebirthUnderClone"
uiClone2.Parent = Head
local function update()
uiClone.stat.Text = abbreviateNumbers(player.leaderstats.Power.Value + ld.Mass.Value).. " Power"
print("update Power")
end
local function updateRebirth()
if player.leaderstats.Rebirth.Value == 0 then
uiClone2.stat2.Text = "🤓Noob"
print(uiClone2.stat2.Text)
elseif player.leaderstats.Rebirth.Value == 1 then
uiClone2.stat2.Text = "😑Beginner"
print(uiClone2.stat2.Text)
elseif player.leaderstats.Rebirth.Value == 2 then
uiClone2.stat2.Text = "🙂Rookie"
print(uiClone2.stat2.Text)
elseif player.leaderstats.Rebirth.Value == 3 then
uiClone2.stat2.Text = "🔰Novice"
elseif player.leaderstats.Rebirth.Value == 4 then
uiClone2.stat2.Text = "🧑🎓 Learner"
elseif player.leaderstats.Rebirth.Value == 5 then
uiClone2.stat2.Text = "🎓Trainee"
elseif player.leaderstats.Rebirth.Value == 6 then
uiClone2.stat2.Text = "👩🏻💻Apprentice"
elseif player.leaderstats.Rebirth.Value == 7 then
uiClone2.stat2.Text = "🥊Amateur"
elseif player.leaderstats.Rebirth.Value == 8 then
uiClone2.stat2.Text = "🚆Intermediate"
end
end
update()
wait(1)
updateRebirth()
--player.leaderstats.Power:GetPropertyChangedSignal("Value"):Connect(update)
--player.leaderstats.Mass:GetPropertyChangedSignal("Value"):Connect(update)
--player.leaderstats.Rebirth:GetPropertyChangedSignal("Value"):Connect(updateRebirth)
player.leaderstats.Power.Changed:Connect(update)
player.leaderstats.Mass.Changed:Connect(update)
player.leaderstats.Rebirth.Changed:Connect(update)
character.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
end)
end)
Here is what I would do, since these are values, instead of using :GetPropertyChangedSignal Just use .Changed, The value’s changed property only fires when the value of the value changes, so you don’t have to worry about the event firing when the value does not change, just write this instead.
player.leaderstats.Power.Changed:Connect(update) -- Just a reminder when using changed it returns the value.
local ServerStorage = game:GetService("ServerStorage")
local statUnder = ServerStorage:WaitForChild("statUnder")
local abbreviations = {
"",
"K",
"M",
"B",
"T"
}
local function abbreviateNumbers(Number)
for i = 1, #abbreviations do
if Number < 10 ^ (i * 3) then
if abbreviations[i] == "∞" then
return "∞"
else
return math.floor(Number / ((10 ^ ((i - 1) * 3)) / 100)) / (100) .. abbreviations[i]
end
elseif tostring(Number) == "Inf" then
return "∞"
end
end
end
local RebirthValues = {
[0] = "🤓Noob",
[1] = "😑Beginner",
[2] = "🙂Rookie",
-- ... complete the list
}
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local leaderstats = player:WaitForChild("leaderstats")
local Power = leaderstats:WaitForChild("Power")
local Mass = leaderstats:WaitForChild("Mass")
local Rebirth = leaderstats:WaitForChild("Rebirth")
local Head = character:WaitForChild("Head")
repeat task.wait(0.35) until character:FindFirstChild("Head")
Head = character.Head
local uiClone = statUnder:Clone()
uiClone.Name = "StatUnderClone"
uiClone.Parent = Head
local uiClone2 = ServerStorage:WaitForChild("rebirthUnder")
uiClone2.Name = "RebirthUnderClone"
uiClone2.Parent = Head
local function update()
uiClone.stat.Text = abbreviateNumbers(Power.Value + Mass.Value).. " Power"
print("update Power")
end
local function updateRebirth()
uiClone2.stat2.Text = RebirthValues[Rebirth.Value]
end
update()
task.wait(1)
updateRebirth()
Power.Changed:Connect(update())
Mass.Changed:Connect(update())
Rebirth.Changed:Connect(updateRebirth())
character.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
end)
end)
local abbreviations = {
"",
"K",
"M",
"B",
"T"
}
local function abbreviateNumbers(Number)
for i = 1, #abbreviations do
if Number < 10 ^ (i * 3) then
if abbreviations[i] == "∞" then
return "∞"
else
return math.floor(Number / ((10 ^ ((i - 1) * 3)) / 100)) / (100) .. abbreviations[i]
end
elseif tostring(Number) == "Inf" then
return "∞"
end
end
end
local RebirthValues = {
[0] = "🤓Noob",
[1] = "😑Beginner",
[2] = "🙂Rookie",
-- ... complete the list
}
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local Power = script.Power
local Mass = script.Mass
local Rebirth = script.Rebirth
local function update()
print(abbreviateNumbers(Power.Value + Mass.Value).. " Power")
end
local function updateRebirth()
print(RebirthValues[Rebirth.Value])
end
update()
updateRebirth()
Power.Changed:Connect(update)
Mass.Changed:Connect(update)
Rebirth.Changed:Connect(updateRebirth)
character.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
end)
end)
so the issue seems to be getting the UIs from serverstorage. Maybe change the location to lighting?