Neither MouseButton1Click or Activated working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want it to print something when I click on the gui button.

  1. What is the issue? Include screenshots / videos if possible!

  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I searched on developer hub and I was searching on similiar questions to this.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local Events = game.ReplicatedStorage:WaitForChild("Events")
local SendOrderEvent = Events:WaitForChild("SendOrder")

script.Parent.MouseButton1Click:Connect(function()
	
	print("Button pressed!")
	
	if game.ReplicatedStorage.Values.PlayerName ~= nil then
		
		print("Firing event...")
		
		local Value = game.ReplicatedStorage.Values.PlayerName.Value
		
		SendOrderEvent:FireServer(Value)
		
	end
	
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Yes, I only want it to activate if there is a value.

The PlayerName object is a StringValue

Try using this script and let me know if there are any errors.

local Events = game.ReplicatedStorage:WaitForChild("Events")
local SendOrderEvent = Events:WaitForChild("SendOrder")

script.Parent.MouseButton1Click:Connect(function()
    print("Button pressed!")

    if game.ReplicatedStorage.Values.PlayerName.Value ~= nil then
        print("Firing event...")
        local Value = game.ReplicatedStorage.Values.PlayerName.Value
        SendOrderEvent:FireServer(Value)
    end
end)

Still nothing. Ignore this, it’s just to get to 30 letters.

Are you getting any errors? What is being printed?

Nothing is being printed at all.

Only errors from other scripts that I am not going to worry about right now.

Maybe one of your other scripts is causing the error. I just tested this script with line 8 changed to

if game.ReplicatedStorage.Values.PlayerName.Value ~= "" then

and it seems to be working well.

I had the script in the wrong place, didn’t realise I didn’t even have it parented to the button. Don’t be stoopid like me.