MouseButton1Click returns nil

script.Parent.MouseButton1Click:Connect(function(player)
	print(player)
end)

result:
image

its a local script inside of a screen gui

1 Like

you can get the player by game.Players.LocalPlayer since it’s done on the local script instead of grabbing the player via MouseButton1Click

2 Likes

true mousebutton1click event does not return player try this:
Make sure its in a local script

script.Parent.MouseButton1Click:Connect(function()
	local player = game:GetService("Players").LocalPlayer
	print(player)
end)
2 Likes

In addition to what @Mister33j said, GuiButton.MouseButton1Click doesn’t return anything.

2 Likes

Well, I was scrolling through the devforum and i saw a post about mouse button 1 click which stated that it does return the player who clicked it. Thank you for clearing it up

1 Like

You most likely saw ClickDetector.MouseClick as that returns the player

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.