MouseButton1Click but on a normal script, not local

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 would like to find a function to transfert the MouseButton1Click on a not local script.

  2. What is the issue? Include screenshots / videos if possible!
    When I use MouseButton1Click on a not local script it doesn’t work, and i can’t find another solution.

button.MouseButton1Click:Connect(function()
	--code
	end)
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Tried searching around, but only local scripts came out.

Put your script inside ServerScriptService, might work

The problem is that it is connected to a GUI in the player. So if i move it there i won’t be able to gain the player anymore, since not local script do not have the: local player = game.Players.LocalPlayer

MouseButton1Click only works on the client. If you want your code to run on the server, use a RemoteEvent to fire the code on the server.

1 Like
game:GetService("Players").PlayerAdded:Connect(function(player)
	player.PlayerGui:WaitForChild("ScreenGui").TextButton.MouseButton1Click:Connect(function()
		print(player)
	end)
end)

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