Ad
Log in to vote
0

Surface GUI in Workspace won't get the Player That Clicked it?

Asked by 4 days ago

I have a surface GUI in workspace, it's a shop and it has a buy button in it. When the buy button is clicked I want it to fireserver to purchase the weapon for the player. When it's clicked it can't get the player that clicked it though. Any help?

script.Parent.MouseButton1Click:connect(function(Player)
  print("Button1 Clicked"..Player.Name)
end)

Hi.

Looks like you're using an ad blocker.

That's fine...

No, it really is.

Just, I mean, we put a lot of work into this site, you know?

It would be really really appreciated if you would turn off your ad blocker for our website...

We tried really hard to make our ads as unobtrusive as possible.

If you really hate ads, would you consider a $2 donation via Patreon?

Here's the link.

We love you. We hope you love us too.

.

..

...

Now back to your regularly scheduled Scripting Helpers....

...

..

.

1 answer

Log in to vote
0
Answered by
Goulstem 7591 Administrator Badge of Merit
4 days ago
Edited 4 days ago

MouseButton1Click does not return the player who clicked. You can just use the LocalPlayer if you put the ScreenGui in StarterGui and set its Adornee Property.

Note: connect is deprecated, use Connect.
local Player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
    print("Button1 Clicked"..Player.Name)
end)
0
I tried that and it printed nothing? Neodyne 0 — 4d
0
My bad I hadn't read your question properly. Edited. Goulstem 7591 — 4d
Ad

Answer this question



Ad