generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: index global 'cl' (a nil value)

Previous Thread :: Next Thread 
Tokimonu is not online. Tokimonu
Joined: 18 Sep 2009
Total Posts: 643
06 Jun 2015 12:28 AM
studio is so wonky rn, i'm being srs
so like, here's my function

function mtl(plr, msg)
frame = Instance.new("Frame")
frame.BackgroundTransparency = 1
frame.Size = UDim2.new(1,0,0,20)

nl = Instance.new("TextLabel", frame)
nl.Name = "NameLabel"
nl.Text = plr.Name
nl.TextColor3 = Color3.new(255,255,255)
nl.BackgroundTransparency = 1
nl.Font = "SourceSansBold"
nl.FontSize = Enum.FontSize.Size12
nl.TextScaled = true
nl.TextXAlignment = Enum.TextXAlignment.Right
nl.Size = UDim2.new(0,80,1,0)

if nl.Text == "Tokimonu" then
plr.Name.TextColor3 = Color3.new(255, 212, 80)
end

cl = Instance.new("TextLabel", frame)
cl.Name = "ChatLabel"
cl.TextColor3 = Color3.new(255/255, 255/255, 255/255)
cl.Font = Enum.Font.SourceSans
cl.FontSize = Enum.FontSize.Size10
cl.TextScaled = true
cl.TextXAlignment = Enum.TextXAlignment.Left
cl.Size = UDim2.new(1,-90,1,0)
cl.Position = UDim2.new(0,-90,0,0)

for i,v in pairs(game.Players:GetChildren()) do
v:WaitForChild("PlayerGui")
frame.Parent = v.KaxionChatGui.KaxionChats
end
end

here's the part where it's erroring (line 66)

UserInputService.InputBegan:connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.Slash then
cl:CaptureFocus() --line 66
if input.KeyCode == Enum.KeyCode.Return then
mtl(plr.Name, cl.Text)
end
end
end
end)

i know that attempt to index global 'cl' a nil value means that it can't find the thing, but i already defined it so i'm just like what

hopefully someone can help i'm tired
Report Abuse
Proxemics is not online. Proxemics
Joined: 30 Oct 2013
Total Posts: 2542
06 Jun 2015 12:30 AM
What are you trying to do?

7/11 was an inside job
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
06 Jun 2015 12:31 AM
cl isn't defined at that point.
Report Abuse
Tokimonu is not online. Tokimonu
Joined: 18 Sep 2009
Total Posts: 643
06 Jun 2015 12:31 AM
basically, this is for a chat gui
the function creates the textlabel with the name and message, the UIS detects when the user presses / and return or enter

btw sorry i'm so tired i forgot to leave the circumstances in the first post qq
Report Abuse
Tokimonu is not online. Tokimonu
Joined: 18 Sep 2009
Total Posts: 643
06 Jun 2015 12:32 AM
@cnt

cl is global, not local
it shouldn't need to be re-defined
Report Abuse
Proxemics is not online. Proxemics
Joined: 30 Oct 2013
Total Posts: 2542
06 Jun 2015 12:33 AM
Same as what cntkillme said.
cl isn't defined, as it's in a separate function.
Try working around that.

7/11 was an inside job
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
06 Jun 2015 12:33 AM
It NEVER WAS defined is what I'm saying. It is defined when you FIRST call the function, which happens to be AFTER you use it.
Report Abuse
Proxemics is not online. Proxemics
Joined: 30 Oct 2013
Total Posts: 2542
06 Jun 2015 12:34 AM
Let me rephrase that.
You're initializing cl in a function that's not run while you're using the UI service.

7/11 was an inside job
Report Abuse
Tokimonu is not online. Tokimonu
Joined: 18 Sep 2009
Total Posts: 643
06 Jun 2015 12:34 AM
oh, well, crap.
any tips or suggestions on how I could fix this?
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
06 Jun 2015 12:36 AM
Here is an amazingly genius idea: Create it outside of the function.
Report Abuse
Tokimonu is not online. Tokimonu
Joined: 18 Sep 2009
Total Posts: 643
06 Jun 2015 12:41 AM
wHHAAAAAtTtTTtTTTT
i never would have thought of that, man
you're like sooo good

on a serious note, if I were to create it outside of the function then how would i set the text with the same arguments?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image