|
| 08 Sep 2015 08:52 PM |
function p() print() end function Night1() p() end function Night2() p() end function Night3() p() end function Night4() p() end game.Players.PlayerAdded:connect(function(p) local nights = {Night1, Night2, Night3, Night4} nights[1]()
end)
am i using bad syntax
https://www.youtube.com/watch?v=-AvRvI9Klu0&t=159s |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2015 08:55 PM |
| It looks fine. Your indentation is off, but it's nothing that would prevent it from working. |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2015 09:16 PM |
not only is it horrendously simple but yes, you are
MY SIDES HAVE LEFT THE GALAXY |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2015 09:57 PM |
you also don't really need that table. since the functions are already there
MY SIDES HAVE LEFT THE GALAXY |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2015 10:17 PM |
| Well I'm not a techy, but it could be because the value for player (p) is the same as the name for the function |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2015 10:18 PM |
The indenting was bothering me
function p() print() end function Night1() p() end function Night2() p() end function Night3() p() end function Night4() p() end game.Players.PlayerAdded:connect(function(p) local nights = {Night1, Night2, Night3, Night4} nights[1]() end) |
|
|
| Report Abuse |
|
|
Everment
|
  |
| Joined: 08 Oct 2009 |
| Total Posts: 6020 |
|
|
| 08 Sep 2015 10:21 PM |
@mr: p only is defined in it's scope; it doesn't extend to an exterior function's scope (that's not the issue)
@op: assuming you actually put something inside of your print and your script is a normal script that actually runs on the server, that script works. (for reference playeradded doesn't fire on the client last i recall) |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2015 10:24 PM |
| Thats what I thought, lua would never error with that, but we are dealing with roblox here e.e |
|
|
| Report Abuse |
|
|
|
| 09 Sep 2015 07:34 PM |
I removed the event handler and pasted all the code without the event part in the lua interpreter didnt work |
|
|
| Report Abuse |
|
|
|
| 13 Sep 2015 10:00 PM |
never use tables for functions
MY SIDES HAVE LEFT THE GALAXY |
|
|
| Report Abuse |
|
|
|
| 13 Sep 2015 10:03 PM |
local function p() print("WOA") end local nights = { ["Night1"] = function() p() end; ["Night2"] = function() p() end; ["Night3"] = function() p() end; ["Night4"] = function() p() end; ["Night5"] = function() p() end; }
game.Players.PlayerAdded:connect(function(p) nights[1]() end)
#code return |
|
|
| Report Abuse |
|
|
RiftTalon
|
  |
| Joined: 02 Dec 2009 |
| Total Posts: 405 |
|
|
| 13 Sep 2015 10:10 PM |
-- This is all you need, nothing else.
function p() print() end
game.Players.PlayerAdded:connect(function() p() end)
-- Also, your script serves no purpose. :/ |
|
|
| Report Abuse |
|
|