here is my ModuleScript:
game.Players.PlayerAdded:connect(function(player)-- this is just so I can declare the player plr = player.Name end) function waitforit(object) game.Workspace:WaitForChild(object) end function message(parent ,text, staytime) msg = Instance.new("Message") msg.Parent = parent msg.Text = text if staytime > 0 then wait(staytime) msg:destroy() end end function hint(text, staytime) playergui = game.Players.plr.PlayerGui gui = Instance.new("ScreenGui") gui.Parent = playergui gui1 = Instance.new("TextLabel") gui1.Text = text gui1.Size.X = 1000 gui1.Size.Y = 50 if staytime > 0 then wait(staytime) gui1:destoy() gui:destoy() end end
now I want to be able to call a function like this:simplemodule.message("game.Workspace", "hello", 30)
also none of these work can someone tell me what I did wrong?
What happened was you didn't return a table. Tables are required to add functions like simplemodule.message()
local tbl = {} game.Players.PlayerAdded:connect(function(player)-- this is just so I can declare the player plr = player.Name end) -- You can also use function tbl:waitforit(object) so it can be a real method. function tbl.waitforit(object) game.Workspace:WaitForChild(object) end function tbl.message(parent ,text, staytime) msg = Instance.new("Message") msg.Parent = parent msg.Text = text if staytime > 0 then wait(staytime) msg:destroy() end end function tbl.hint(text, staytime) playergui = game.Players.plr.PlayerGui gui = Instance.new("ScreenGui") gui.Parent = playergui gui1 = Instance.new("TextLabel") gui1.Text = text gui1.Size.X = 1000 gui1.Size.Y = 50 if staytime > 0 then wait(staytime) gui1:destoy() gui:destoy() end end return tbl
If I helped accept me as an answer and vote me up. Thank you! Also, sorry if any of this info is wrong. Its probably because I'm tired. D:
Game.Players.PlayerAdded:connect(function(player) plr = Game.Players.LocalPlayer end) function waitforit(object) game.Workspace:WaitForChild(" Object") end function hint(Parent, text, StayTime) msg = instance.new("Message") msg.Parent = game.Workspace -- beacuse workspace is where everything goes. msg.Text = "Wat is your text here" if staytime > 0 then wait() -- put seconds msg:Destroy() -- beacuse msg was on Every Line. end end function hint(text, StayTime) gui = instance.new("ScreenGUI") gui.Parent = Game.StarterGUI -- you forgot the frame. Frame = Instance.new("Frame") TextLabel = Instance.new("TextLabel") gui.Text = "" -- put your text between the "" gui.Size.X = 1000 gui.Size.Y = 50 if staytime > 0 then wait() -- put seconds between () like the code UnTop Frame:Destroy() TextLabel:Destroy() gui:Destroy() end end -- np. also Local Script.