|
| 01 Jul 2015 07:12 AM |
| This may seem basic, but I never learned how, can anyone tell me? |
|
|
| Report Abuse |
|
|
OzzyFin
|
  |
| Joined: 07 Jun 2011 |
| Total Posts: 3600 |
|
| |
|
|
| 01 Jul 2015 07:51 AM |
Hm, I ran that script, and for some reason I'm getting this in output.
05:50:44.464 - Players.Player.PlayerGui.DropStuff:8: attempt to call global 'drop_all_items' (a nil value) 05:50:44.464 - Stack Begin 05:50:44.465 - Script 'Players.Player.PlayerGui.DropStuff', Line 8 05:50:44.465 - Stack End |
|
|
| Report Abuse |
|
|
| |
|
|
| 01 Jul 2015 07:55 AM |
Heh, I fixed it, good enough for a newbie.
local Player = game.Players.LocalPlayer local PlayerStats = ReplicatedStorage.PlayerStats["Data_"..game.Players.LocalPlayer.Name]
drop_all_items = require(Common_Function_Modules.DropAllItems)(Player, PlayerStats)
drop_all_items() |
|
|
| Report Abuse |
|
|
|
| 01 Jul 2015 07:55 AM |
| The code within the Module script, before you get confused. |
|
|
| Report Abuse |
|
|
|
| 01 Jul 2015 07:58 AM |
@power
I fixed it already, I just added (Player, PlayerStats) since that was what the Module was trying to fetch from the LocalScript.
:P |
|
|
| Report Abuse |
|
|
|
| 01 Jul 2015 08:00 AM |
Nevermind, I just tested it and now it's just nil again.
Here's the script:
local ReplicatedStorage = Game:GetService("ReplicatedStorage") local Module_Engine = ReplicatedStorage:WaitForChild("Module_Engine") local Common_Function_Modules = Module_Engine:WaitForChild("Common_Function_Modules") local Player = game.Players.LocalPlayer local Char = Player.Character local PlayerStats = ReplicatedStorage.PlayerStats["Data_"..game.Players.LocalPlayer.Name]
local drop_all_items = require(Common_Function_Modules.DropAllItems)(Player, PlayerStats)
while wait(0) do if Char.Humanoid.Health == 0 then drop_all_items() end end |
|
|
| Report Abuse |
|
|
| |
|
|
| 01 Jul 2015 08:19 AM |
local func = require(Common_Function_Modules.DropAllItems) > Returns the contents from the module, right now a func
func(arg) -- call the func |
|
|
| Report Abuse |
|
|
|
| 01 Jul 2015 08:19 AM |
Module scripts are made to be objects like you see in workspace, libraries, or service-like tools.
Check out what OOS (object oriented scripting) is.
http://wiki.roblox.com/index.php?title=OOP
You should be using a type of format, depending on what you are making, like this.
local module = {}
module.new = function(parameter) local this = { Example = parameter; }
this.SetExample = function(self, a) self.Example = a end
return this end
return module
---
local module = require(script.ModuleScript)
local a = module.new("Test") print(a.Example) --> Test a:SetExample("Asd") -- or you could do a.SetExample(a, "Asd") print(a.Example) --> Asd |
|
|
| Report Abuse |
|
|
|
| 01 Jul 2015 08:20 AM |
| The reason why it says it's nil, is because you set the variable not to the function, but to the function AFTER it ran; so if it returns nothing it's nil. |
|
|
| Report Abuse |
|
|