Hello everyone,
i have a problem with my screen bar if the player life is getting higher(power value = maxhealth+powervalue) then my health bar is sizing to much (Screen Shot) maybe someone see the error or soluation ?
local Players = game:GetService("Players") local player = Players.LocalPlayer or Players:GetPropertyChangedSignal("LocalPlayer"):wait() local character = player.Character or player.CharacterAdded:wait() local PlayerLevel = player:WaitForChild("leaderstats").Level.Value local human = character:FindFirstChild("Humanoid") local health = human.Health local maxhealth = human.MaxHealth local PlayerXP = player:WaitForChild("playerdata"):WaitForChild("XP") local xpToLevelUp = function(level) return 100 + level * 5 end while wait() do local pourcentage = math.floor(player:WaitForChild("playerdata"):WaitForChild("XP").Value/xpToLevelUp(player:WaitForChild("leaderstats"):WaitForChild("Level").Value) * 100) if health then script.Parent:TweenSize(UDim2.new(player:WaitForChild("playerdata"):WaitForChild("XP").Value/xpToLevelUp(player:WaitForChild("leaderstats"):WaitForChild("Level").Value), 0, 1, 0)) script.Parent.Parent.TextLabel.Text = pourcentage.. "%" end end
i already tryed something like that
if health == maxhealth or health > maxhealth then script.Parent.Size = UDim2.new(1, 0,1, 0) end
The problem here is you're not checking if the size is greater than the maximum. When using Scale, you want to make sure its not going above 1, or
local xSize = player:WaitForChild("playerdata"):WaitForChild("XP").Value/xpToLevelUp(player:WaitForChild("leaderstats"):WaitForChild("Level").Value) --If the size is greater than 1, just set it to 1 script.Parent:TweenSize(UDim2.new((xSize < 1 and xSize) or 1, 0, 1, 0))