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

Why wont my createlabel function work correctly?

Asked by 8 years ago

I am trying to make it easier by making a function that makes textlabels automatically

When I do this they are all together in one position.

01local Plr = game.Players.LocalPlayer
02 
03local function Cc(Nme, Dsc, Prnt, Pos1)
04    local t = Instance.new("TextLabel", Prnt)
05    t.Name = Nme
06    t.BackgroundTransparency = 0.35
07    t.BackgroundColor3 = Color3.new(0,0,0)
08    t.Size = UDim2.new(0,280,0,15)
09    t.BorderSizePixel = 0
10    t.TextColor3 = Color3.new(255,255,255)
11    t.FontSize = Enum.FontSize.Size10
12    t.TextWrapped = true
13    t.Text = Dsc
14    t.Position = UDim2.new(0,7.5,0,0+Pos1)
15end
View all 52 lines...

Please help

0
not an answer, but those are some bad variable names Kampfkarren 215 — 8y
0
Variable names dont matter when they are just used in a script ;) BadLuke1 2 — 8y
0
To correct you, variable names do matter, you should never overwrite reserved commands with a variable name Sublimus 992 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago

misiunicholas is right. The Pos1 argument is always set to 17 in the five calls in lines 44 to 48. Either change these, or do the following:

01local Plr = game.Players.LocalPlayer
02local lastTextLabelPosition = 0
03 
04local function Cc(Nme, Dsc, Prnt, Pos1)
05    local t = Instance.new("TextLabel", Prnt)
06    t.Name = Nme
07    t.BackgroundTransparency = 0.35
08    t.BackgroundColor3 = Color3.new(0,0,0)
09    t.Size = UDim2.new(0,280,0,15)
10    t.BorderSizePixel = 0
11    t.TextColor3 = Color3.new(255,255,255)
12    t.FontSize = Enum.FontSize.Size10
13    t.TextWrapped = true
14    t.Text = Dsc
15    t.Position = UDim2.new(0,7.5,0,lastTextLabelPosition+Pos1)
16    lastTextLabelPosition= lastTextLabelPosition+Pos1
17end
Ad
Log in to vote
1
Answered by 8 years ago

Well when you execute the function from line 44 to 48 you set the argument Pos1 all to 17

Answer this question