Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Message Functions Help?

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()

1 comment

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.

2 answers

✓ Accepted answer

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

5 comments

0

yumtaste, you need to explain it like how I did, also this script can be MUCH simpler.

0

You need to explain how the script works. Just posting the script isn't going to help him learn.

0

Geez. Don't downvote me just because I didn't explain...

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.

0

Why do I have so many downvotes if my answer is right AND explained...

  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!

This discussion is preserved as it was. New answers, comments, and votes are closed.