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

How do you fix the errors in my script that displays a text above character's head?

Asked by 5 years ago
local player = game.Players.LocalPlayer
local charac = player.Character

local billboardthing = Instance.new("BillboardGui")
billboardthing.Enabled = true
billboardthing.Name = "thingy"
billboardthing.Parent = player.Character.Head

aq = "Antique"

local txtkk = Instance.new("TextLabel")
txtkk.Parent = game.player.charac.Head.thingy
txtkk.Name = "label"
txtkk.Font = "Antique"
txtkk.Text = "sample text"
txtkk.BackgroundTransparency = 1
txtkk.TextSize = "30"

It ain't displaying "sample text " above my character's head.

0
where is this script and what type of script is it? User#5423 17 — 5y
0
A LocalScript and it's in Workspaace. Apewlice 0 — 5y
0
local scripts do not run in the workspace only under the players character model. User#5423 17 — 5y

1 answer

Log in to vote
0
Answered by
CPF2 406 Moderation Voter
5 years ago
Edited 5 years ago

Well for starters you made three simple mistakes.

  1. You set the TextLabel's parent incorrectly
txtkk.Parent = game.player.charac.Head.thingy

-- fixed version

txtkk.Parent = charac.Head.thingy
  1. You set the Font property incorrectly.
txtkk.Font = "Antique"

-- fixed version

txtkk.Font = Enum.Font.Antique

and 3. (not really a mistake, but still worth mentioning) You set the FontSize using a string value.

txtkk.TextSize = "30"

-- fixed version

txtkk.TextSize = 30

But even after these fixes, it doesn't show up, that is because you forgot to set the size of the TextLabel and the BillboardGui. (You also should've set a StudOffset to make the label show properly)

Here is a fixed version of your script.

local player = game.Players.LocalPlayer
local charac = player.Character

local billboardthing = Instance.new("BillboardGui")
billboardthing.Enabled = true
billboardthing.Name = "thingy"
billboardthing.Parent = charac.Head
billboardthing.Size = UDim2.new(0,100,0,50)
billboardthing.StudsOffset = Vector3.new(0,2,0)

aq = "Antique"

local txtkk = Instance.new("TextLabel")
txtkk.Parent = charac.Head.thingy
txtkk.Name = "label"
txtkk.Font = Enum.Font.Antique
txtkk.Text = "sample text"
txtkk.BackgroundTransparency = 1
txtkk.TextSize = 30
txtkk.Size = UDim2.new(1,0,1,0)

EDIT: Also make sure to put the script in StarterGui,StarterPack,StarterPlayerScripts,or StarterCharacterScripts

0
The font part is incorrect. You **can** use `string` to assign fonts. Zafirua 1348 — 5y
0
Oh wow, I didn't know that, good to know. CPF2 406 — 5y
Ad

Answer this question