Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

This hp bar works perfectly in the studio, but the sizes are all messed up in the actual game?

Asked by
Echtic 128
4 years ago

I am using a gui rescaler plugin that does work on everything, for some reason the size gets messed up anyways, and like i stated in the title it does work perfectly fine in the studio no matter how much i strech the screen it won't change.

Here's the script:

local frame = script.Parent
local background = frame:WaitForChild("HpBackground")
local hp = frame:WaitForChild("Hp")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character
local amount = frame:WaitForChild("Amountofhp")

local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")

repeat wait() until character:FindFirstChild("Humanoid")

local humanoid = character:FindFirstChild("Humanoid")

humanoid.Changed:Connect(function(Property)

    if Property == "Health" then


    local health = humanoid.Health
    local maxhealth = humanoid.MaxHealth    

    hp:TweenSize(UDim2.new( 0,health/maxhealth * 412,0,21),Enum.EasingDirection.Out,Enum.EasingStyle.Linear,.2) 

    amount.Text = math.floor(health+0.5) .. "/" .. math.floor(maxhealth+0.5)


    end


end)
0
the gui sizes? royaltoe 5144 — 4y
0
0, 412 , 0 , 21 Echtic 128 — 4y
0
that's the size of the frame that tweens Echtic 128 — 4y
1
It may be because you're tweening hp using the Offset values, instead of using Offset try using Scale instead UDim2.new(xScale, xOffset, yScale, yOffset) Godlydeathdragon 227 — 4y
View all comments (2 more)
0
then the question is how do i use those scale values when they are 0 and i am multiplying Echtic 128 — 4y
0
nvm i figured out a way thanks Echtic 128 — 4y

Answer this question