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 » Scripting Helpers
Home Search
 

Re: attempt to call a nil value

Previous Thread :: Next Thread 
Oskee is not online. Oskee
Joined: 24 Jul 2014
Total Posts: 297
10 Nov 2014 01:27 PM
I see no nil values here. I checked and made sure everything was in it's place.

game.Players.PlayerAdded:connect(function(plr)
function quest()
local chatgui = script.Parent.Chat
chatgui:Clone().Parent = plr.PlayerGui
end
end)

script.Parent.MouseButton1Down:connect(quest)
Report Abuse
HyroadCoder is not online. HyroadCoder
Joined: 15 Jul 2014
Total Posts: 813
10 Nov 2014 01:28 PM
Wow. You did this completely wrong.

You can't call a function from a function. And plr is a nil value.
Report Abuse
ShadowOfCrimson is not online. ShadowOfCrimson
Joined: 14 Dec 2009
Total Posts: 2153
10 Nov 2014 01:28 PM
local chatgui = script.Parent.Chat
chatgui:Clone().Parent = plr.PlayerGui

that means one of these dont exist as written

im guessing its chatgui
Report Abuse
Oskee is not online. Oskee
Joined: 24 Jul 2014
Total Posts: 297
10 Nov 2014 01:29 PM
@Hyroad

then show me senpai
Report Abuse
HyroadCoder is not online. HyroadCoder
Joined: 15 Jul 2014
Total Posts: 813
10 Nov 2014 01:31 PM
Rewrite it.
Report Abuse
powertool is not online. powertool
Joined: 01 Feb 2008
Total Posts: 3771
10 Nov 2014 01:32 PM
Hyroad gtfo

You can create functions within functions. I do so fairly often.
Furthermore, it is incredibly possible to call a function from within a function. I do so more often.

OP, I see nothing implicitly wrong with this, besides some strange cloning things.
I've tried to make it more reliable, but no guarantees. I also noticed that plr isn't carried on down into quest(), so for the sake of fixing this, I've just trashed that inner function and made it part of the anon function.

game.Players.PlayerAdded:connect(function(plr)
local chatgui = script.Parent.Chat
local cgc = chatgui:Clone()
cgc.Parent = plr.PlayerGui
end)
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
10 Nov 2014 01:34 PM
Though that is somewhat inefficient. :/ lol ^^
-=Robo=-
Report Abuse
HyroadCoder is not online. HyroadCoder
Joined: 15 Jul 2014
Total Posts: 813
10 Nov 2014 01:35 PM
His script is trash. ;-;
Report Abuse
powertool is not online. powertool
Joined: 01 Feb 2008
Total Posts: 3771
10 Nov 2014 01:36 PM
It's clear, concise, and works. There isn't a lot of optimizing that can be done on it. I personally prefer clear, concise, and working over convoluted, optimized, hard to edit, and working.
Report Abuse
Oskee is not online. Oskee
Joined: 24 Jul 2014
Total Posts: 297
10 Nov 2014 01:36 PM
@Power

Thanks for helping but your script destroys the meaning of the player clicking the block(or specifically, the image button in a surface gui) to activate the gui.
Report Abuse
HyroadCoder is not online. HyroadCoder
Joined: 15 Jul 2014
Total Posts: 813
10 Nov 2014 01:36 PM
And I'd prefer you to stop talking.
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
10 Nov 2014 01:38 PM
There is quite a bit he can do.
He can localize that function in the global scope and put it in the connection lines parameter rather than committing to a pseudo function and then creating a new function every time the event is called, that's ridiculous. lol
-=Robo=-
Report Abuse
Oskee is not online. Oskee
Joined: 24 Jul 2014
Total Posts: 297
10 Nov 2014 01:40 PM
so trying this would not work?

game.Players.PlayerAdded:connect(function(player)
function quest(player)
cgui = script.Parent.Chat
local cgc =cgui:Clone()
cgc.Parent = player.PlayerGui
end
end)

script.Parent.MouseButton1Down:connect(quest)
Report Abuse
HyroadCoder is not online. HyroadCoder
Joined: 15 Jul 2014
Total Posts: 813
10 Nov 2014 01:40 PM
Lol. Powertool sent me a message:

No need to act like a stuck-up self-important prick.


He knows I'm right, doe.
Report Abuse
powertool is not online. powertool
Joined: 01 Feb 2008
Total Posts: 3771
10 Nov 2014 01:42 PM
Hyroad, you know damn well what I mean. If you're so convinced you can do it better, then do so. Stop acting like you're superior unless you can prove it.
Report Abuse
ShadowOfCrimson is not online. ShadowOfCrimson
Joined: 14 Dec 2009
Total Posts: 2153
10 Nov 2014 01:43 PM
--calm down people--
Report Abuse
HyroadCoder is not online. HyroadCoder
Joined: 15 Jul 2014
Total Posts: 813
10 Nov 2014 01:45 PM
I'm a little rusty with billboards. uhh let's see..

Report Abuse
HyroadCoder is not online. HyroadCoder
Joined: 15 Jul 2014
Total Posts: 813
10 Nov 2014 01:47 PM
I guess when you click the buttons it doesn't return the player who clicked. So yuh, this is tricky.

Report Abuse
Oskee is not online. Oskee
Joined: 24 Jul 2014
Total Posts: 297
10 Nov 2014 01:48 PM
It isn't a billboard, it is a surfacegui with a image button in it. The purpose is that if you click that image button, a gui would be placed in your player's playergui and that gui would have info about the quest.

All I wanted to do was make a simple quest script ;-;
Report Abuse
Looah is not online. Looah
Joined: 22 Feb 2013
Total Posts: 922
10 Nov 2014 01:50 PM
everybody shut up and realize that quest is in the scope of the anonymous function linked to the event of PlayerAdded

correct code;

script.Parent.MouseButton1Down:connect(function()
script.Parent.Chat:clone().Parent=game.Players.LocalPlayer.PlayerGui
end)

shove it in a local script and you're good
Report Abuse
padam11 is not online. padam11
Joined: 11 Feb 2013
Total Posts: 15774
10 Nov 2014 01:51 PM
(tool)lol noob
whenplayer("do it urself noob")


"Counting is paramount."
Report Abuse
Looah is not online. Looah
Joined: 22 Feb 2013
Total Posts: 922
10 Nov 2014 01:52 PM
@OP
well, actually, if it's a surfacegui, make it a local part and then do the stuff to it
wiki says so.
Report Abuse
Oskee is not online. Oskee
Joined: 24 Jul 2014
Total Posts: 297
10 Nov 2014 01:54 PM
But the.. ugh more explaining.
So there is BRICK, that has a SURFACEGUI on it. In that surfacegui is a IMAGEBUTTON. The script is meant so that when the player CLICKS the button, it would clone it into their PLAYERGUI. So putting it in a localscript will NOT work.
Report Abuse
Looah is not online. Looah
Joined: 22 Feb 2013
Total Posts: 922
10 Nov 2014 01:54 PM
@above
no it works
nob
Report Abuse
Oskee is not online. Oskee
Joined: 24 Jul 2014
Total Posts: 297
10 Nov 2014 01:55 PM
I've never heard of this 'Local Part'.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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