Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

my modulescript is a fail, can someone tell me what is wrong?

Asked by 10 years ago

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?

2 answers

Log in to vote
1
Answered by
Gamenew09 180
10 years ago

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:

0
can i put the hint in every players gui using game.Players:GetChildren().playergui... etc. chabad360 34 — 10y
0
Change the name of the hint gui to something like HintGui. Then loop through the players and check if the HintGui exists if it does do nothing otherwise just make the hint gui like in the hint function. Hopefully that's right. Gamenew09 180 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago
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.



0
Some Things are spaced like ("Object") its not my fault. digitalzer3 123 — 10y
0
oh you put enw instead of new heehee chabad360 34 — 10y
0
Lol like i said its not me its the website. digitalzer3 123 — 10y
0
also i need to know how to actualy use it like this "simplemodule.message("hello", 3)" chabad360 34 — 10y
View all comments (2 more)
0
number of probs but i hope it works chabad360 34 — 10y
0
Make this a local script im editing noe. digitalzer3 123 — 10y

Answer this question