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

Would this properly run?

Asked by 9 years ago

`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!!"

0
if should be on the 2nd line., SprocketSoldier 0 — 9y
0
And the ends should be on seperate lines SprocketSoldier 0 — 9y
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). BlueTaslem 18071 — 9y

1 answer

Log in to vote
3
Answered by 9 years ago

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

0
Ah, ok. And also how come mine didn't show the actual lines of code? SprocketSoldier 0 — 9y
Ad

Answer this question