x = script.Parent y = game.Workspace.Message.Text function onClicked(mouse) wait(1) Instance.new("Message", game.Workspace) wait(1) y = Player.Name.."clicked The button!" wait(3) y = "" end x.ClickDetector.MouseClick:connect(onClicked)
1) You've not defined what 'Player' is anywhere, yet attempt to get its name.
2) You cannot reference a property in that way. When you create a variable and set it to the value of a property, the variable won't point to the property but rather become equal to whatever the value of the property is at that moment in time.
3) You shouldn't really create a new message every time unless you're deleting the old ones (which you weren't). Messages won't display unless their 'Text' property has something in it, meaning you can quite easily just create one and change that each time.
Here's how I'd do it with an anonymous function:
local Message = Instance.new("Message", Workspace) script.Parent.ClickDetector.MouseClick:connect(function(Player) Message.Text = Player.Name .. " clicked the button!" wait(3) Message.Text = "" end)
Which is the same as:
local Message = Instance.new("Message", Workspace) function Clicked(Player) Message.Text = Player.Name .. " clicked the button!" wait(3) Message.Text = "" end script.Parent.ClickDetector.MouseClick:connect(Clicked)
What is the output?
x = script.Parent y = game.Workspace.Message.Text function onClicked(mouse) wait(1) Instance.new("Message", game.Workspace) wait(1) y = player.Name.."clicked The button!" wait(3) y = "" end x.ClickDetector.MouseClick:connect(onClicked)