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

Message Functions Help?

Asked by 9 years ago

I can't seem to make a msg function

Please help me

function msg()

end m = Instace.new("Message", game.Workspace) m.Text = "Howdy, Y'all!" wait(5) m:Remove()

0
PaperVex, please see all of the answers. The first answer posted isn't always the right answer, he didn't explain how this script works. EzraNehemiah_TF2 3552 — 9y

2 answers

Log in to vote
-3
Answered by
yumtaste 476 Moderation Voter
9 years ago

Lol, I see you're new to scripting. Technically, you're supposed to put your code in a code block and ask what's going wrong and give the output; and not ask for scripts. I'll give you this one, but don't expect people to give you scripts.

function createMessage(text, waitTime)
local message = Instance.new("Message", workspace) --creates Message object and puts in in Workspace
message.Text = text --sets message text to text value (look on line 1)
wait(waitTime) --waits for waitTime --(again, line 1)
message:destroy() --destroys message
end
--The beauty of this function is that you can specify the text and time it will last.
createMessage("Howdy, Y'all!", 5) --calls function, you MUST call function, obviously, or nothing will happen

EDIT: I added an explanation because LordDragonZord :I

0
yumtaste, you need to explain it like how I did, also this script can be MUCH simpler. EzraNehemiah_TF2 3552 — 9y
0
You need to explain how the script works. Just posting the script isn't going to help him learn. EzraNehemiah_TF2 3552 — 9y
0
Geez. Don't downvote me just because I didn't explain... yumtaste 476 — 9y
0
I kinda have too, unless you've read all the rules, I wouldn't of downvoted you. I'm just doing what the rules tell me to do. EzraNehemiah_TF2 3552 — 9y
0
Why do I have so many downvotes if my answer is right AND explained... yumtaste 476 — 9y
Ad
Log in to vote
0
Answered by 9 years ago
  1. You need to call the function
  2. You need to have the script in between msg() and end.
  3. Use Destroy() instead of remove(remove is deprecated)
  4. Make "m" local
  5. A short cut: Instead of doing game.Workspace you can just type workspace.

function msg() --Keep the code in between function and end.
    local m = Instace.new("Message", workspace) --workspace is a shortcut for game.Workspace
    m.Text = "Howdy, Y'all!"
    wait(5)
    m:Destroy() --Destroy instead of remove
end
msg() --Call the function

One lined script; Hard to read

function msg() local m = Instace.new("Message", workspace) m.Text = "Howdy, Y'all!" wait(5) m:Destroy() end msg()

7 lined script; easy to read

function msg()
    local m = Instace.new("Message", workspace)
    m.Text = "Howdy, Y'all!"
    wait(5)
    m:Destroy()
end
msg() --7 lined but easy to read.

Hope this helps!

Answer this question