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

Can you tell me what I am doing wrong?

i have bought a book and looked all over the wiki. this still give me no help to making a script. I have done the simple "message script" this is what i have been told to do (my message is "Welcome")Am i in some way doing some thing incorrect? If so please tell me what parts and what i can do to fix them. Also can someone tell me how do get a code to start working? :/

local Message = Instance.new("Welcome")
Message.text = "Welcome"
Message.Parent = game.Workspace
wait(5)
Message:Remove()

1 comment

0

I edited your question to format the code block. Please remember to do this yourself in the future, using the Lua symbol on above the text editor.

3 answers

✓ Accepted answer

Instance.new() create a new ROBLOX Object (like Parts or Models, for example). 'Welcome' is not a valid ROBLOX Object type, so it can't be created. However, 'Message' is a valid ROBLOX Object type.

There are a few more errors that I fixed in the below code:

local Message = Instance.new("Message")
Message.Text = "Welcome" --text is not a valid property name. Text is. Remember, Lua is case-sensitive!
Message.Parent = game.Workspace
wait(5)
Message:Destroy() --Remove() works but should not be used. Use Destroy() instead!

Additionally, Instance.new() takes a second argument: where to put the newly created ROBLOX Object:

local Message = Instance.new("Message", game.Workspace)
Message.Text = "Welcome"
wait(5)
Message:Destroy()

Feel free to PM me on ROBLOX if you would like some personal Lua tutoring, I'd be happy to help!

Also feel free to keep posting specific Lua question on this forum, most everyone here will try to help you fix your code.

9 comments

0

ninja'd

0

;P

0

thanks adark for the code but where od i place it on roblox studio?

0

You need a Script! First, right-click ServerScriptService in the Explorer pane, then click 'Insert', and then 'Script' in the menu that pops up!

0

Thanks for all of your help I will remember this for future scripts, and sure i would love to be tutored.

0

Please mark my answer as accepted, then. :)

0

i dont know how to do that, i was look eirlier

0

There is a button underneath my username to the right of this answer that should say "Accept Answer"

0

i am sorry i can find it, it may be different for the different computers

Code Fixes

  • There is no instance type of Welcome, you need to make it Message.

  • Properties are case sensitive! Message.text should be message.Text.


Efficiency Fixes

  • Remove is deprecated, use Destroy.

  • There's a second argument of the Instance.new function, the parent.


Code

local Message = Instance.new("Message",workspace)
Message.Text = "Welcome"
wait(5)
Message:Destroy()

Change

Message.text = "Welcome"

to

Message.Text = "Welcome"

Also use ':Destroy()' instead of ':Remove()' It's better and reliable.

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