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

How to put this billboard gui on player head?

Asked by
j1011 0
8 years ago

So i'm trying to convert this to billboard gui instead of showing it on player screenGui where will i start?

function CreateGui()
for i, v in pairs(player.PlayerGui:children()) do
if v.className == "ScreenGui" and v.Name == "staminaGui" then
v:remove()
end
end
local g = Instance.new("BillboardGui", player.PlayerGui)
g.Name = "staminaGui"

local c = Instance.new("Frame", g)
c.Visible = false
c.Size = UDim2.new(0,86,0,320)
c.BackgroundTransparency = 1
c.Position = UDim2.new(1,-96,0.5,-160)
c.Name = "Container"

local t = Instance.new("TextLabel", c)
t.Size = UDim2.new(0,0,-0.1,0)
t.Position = UDim2.new(0.3,0,0.5,0)
t.TextXAlignment = "Right"
t.Font = "ArialBold"
t.TextTransparency = 0.1
t.TextColor3 = Color3.new(0,0.6,0.8)
t.TextStrokeColor3 = Color3.new(0,0.2,0.8)
t.TextStrokeTransparency = 0.3
t.FontSize = 6
t.BackgroundTransparency = 1
local t2 = t:Clone()
t2.Parent = c
t2.Size = UDim2.new(0,0,0.1,0)
local l = t:Clone()
l.Parent = c
l.Size = UDim2.new(0,0,0,0)
l.Text = "-----"

local f1 = Instance.new("Frame", c)
f1.Name = "Backing"
f1.ClipsDescendants = true
f1.Size = UDim2.new(1,0,0,0)
f1.BackgroundColor3 = Color3.new(0.8,0,0)
f1.BackgroundTransparency = 1
local f1img = Instance.new("ImageLabel", f1)
f1img.BackgroundTransparency = 1
f1img.Image = "http://www.roblox.com/asset/?id=112474909"
f1img.Size = UDim2.new(1,0,0,c.Size.Y.Offset)

local f2 = Instance.new("Frame", c)
f2.Name = "Overlay"
f2.ClipsDescendants = true
f2.Size = UDim2.new(1,0,1,0)
f2.BackgroundColor3 = Color3.new(0,0,0.8)
f2.BackgroundTransparency = 1
local f2img = Instance.new("ImageLabel", f2)
f2img.BackgroundTransparency = 0
f2img.Image = "http://www.roblox.com/asset/?id=112474911"
f2img.Size = UDim2.new(1,0,0,c.Size.Y.Offset)

function Calculate()
local ysize = c.Size.Y.Offset
local per = (stamina/maxstamina) * c.Size.Y.Offset
local rem = (-(stamina/maxstamina-1)) * c.Size.Y.Offset
f1.Size = UDim2.new(1,0,0,rem)
f2.Size = UDim2.new(1,0,0,per)
f2.Position = UDim2.new(0,0,0,rem)
f2img.Position = UDim2.new(0,0,0,-rem)
t.Text = math.floor(stamina)
t2.Text = maxstamina
end
Calculate()

wait(0.01)
c.Visible = true
end
CreateGui()

1 answer

Log in to vote
0
Answered by 8 years ago

http://wiki.roblox.com/index.php?title=API:Class/BillboardGui/Adornee

Ad

Answer this question