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

Would this properly run?

`game.Players.LocalPlayer:GetMouse() .KeyDown:connect if string.lower (key) == "m" then Instance.new('Hint', Workspace) Hint.Text = "Just a test"

end end)`

Is this something that can properly run? "Sorry ahead of time for asking, I'm trying to learn on mobile!!"

3 comments

0

if should be on the 2nd line.,

0

And the ends should be on seperate lines

0

You should use the Lua button for multiline code display (it'll look like ~~~~ (newline) code code code (newline) ~~~~~~). The backticks are used for code interspersed with writing (inline code).

1 answer

No, that would not work. Let's highlight the reasons:

game.Players.LocalPlayer:GetMouse() .KeyDown:connect if string.lower (key) == "m" then Instance.new('Hint', Workspace) Hint.Text = "Just a test" end end)

From just looking at that code, you can see a few things.

  • You do not properly use the RbxScriptSignal connection.
  • You attempt to access key, a nil value.
  • You try to set the Text property of Hint, also a nil value.

Now, let's fix those problems and clean up your code a little.

game.Players.LocalPlayer:GetMouse() .KeyDown:connect(function(key) 
	if key:lower() == "m" then
		Instance.new('Hint', Workspace).Text = "Just a test"; 
	end;
end);

Sources to learn from: http://wiki.roblox.com/index.php?title=RBXScriptSignal and http://wiki.roblox.com/index.php?title=Variables

1 comment

0

Ah, ok. And also how come mine didn't show the actual lines of code?

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