How can I get a single player from a screenGUI ( mouseButton1Click )

So I’m trying to get the player from a click from the mouse but I don’t get a single player in specific but all the players currently on the server.

I don’t know what to do here, I tried to use RemoteEvents but It seems that it doesn’t work ( at least how I scripted it ), If you can help me you would be doing me a great favor ! :upside_down_face:
image

For i, v in pairs error:

:wink:

1 Like

Make sure you’re using a local script and not a script

Even if it is a BillboardGUI? because It doesn’t show me anything, I click on the “Part” block billboardGUI but it doesn’t fire anything, what can I do there then? :smile:

Can you show me your script? Also no.

Ah, then there is the problem, anyways heres the script:

You can’t put text buttons in billboard guis (or neither surface guis).

And on SurfaceGUI’s? I think Either no?

It seems like you’re calling the Remote Event, but you haven’t set a remote OnClient/OnServer event.

I recommend you to check this : Remote Functions and Events (roblox.com)

To make surface GUIs “clickable” you need to place them in the player’s PlayerGui (aka StarterGui) and set the adornee of the SurfaceGUI to the part. And since you use local scripts to detect when someone clicks it, to get the player you just need to do local Player = game.Players.LocalPlayer, instead of getting it as a parameter (MouseButton1Click doesn’t even have player as the parameter)

1 Like

I did but the problem is that it doesnt fires the remote event

This is because the parameter you sent is not a player. Like what @ShinsokuDev said about the MouseButton1Click.

The player variable he’s sending is nil, and that isn’t even the main problem, main problem is the MouseButton1Click event isn’t even firing, because the surface gui isn’t in the StarterGui.

so what gui you are having issue?
screenGui surfaceGui BillboardGui?

So I need to clone the SurfaceGUI and put it onto PlayerGUI then?

Yeah, move the SurfaceGui to the StarterGui in the explorer
, then set the SurfaceGui’s adornee to the part it was parented to before

That’s the thing, you can’t, if you have the SurfaceGui inside the part, it doesn’t detect mouse clicks, if you want it to detect you need to put it in StarterGui

1 Like

you just can add TextButton then add this script:

script.Parent.TextButton.MouseButton1Click:Connect(function()
	--put here what you need to work when player click on TextButton.
end)

im putted what im writed.
Example_button.rbxl (31.7 КБ)
(test then click on button and look in Output)

Also replace the player with game.Players.LocalPlayer

But TextButton? can you click it on SurfaceGui?