I am trying to print a message that a player clicked the button then do 500 damage to all players. Please explain and help me figure out why this isn't working.
local M = Instance.new("Message", game.Workspace)
local p = game.Players:GetChildren()
function onClicked()
M.Text = "The button was clicked by .. " .. game.Players.LocalPlayer.Character.Name
wait(2)
M:remove()
for i = 1, #p do
p[i].Character.Humanoid:TakeDamage(500)
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

3 comments
Line 7 is one line not sure why it put it on two lines when I copied the code
I also wanted to note the message works but just doesn't display the name of the player that clicked it.
That's okay, it gets wrapped to the next line, on the left it says line 7 and the second part is in line 7 as well showing that it's on the same line. Message is deprecated, so is remove. Check the output for errors