Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you find out who clicked an Image button?

Asked by 8 years ago

I know how to find out the name of the player who clicked a brick using a click detector, but what if I want to find out who clicked a gui? Please answer with some help!

0
A GUI by default is in the Player's PlayerGui unless it is a SurfaceGUI or Billboard GUI. If it is a ScreenGui, just use a localscript to get the LocalPlayer. FearMeIAmLag 1161 — 8y
0
So I just do- if script.Parent.Value==LocalPlayer then -then it will go on? Volodymyr2004 293 — 8y
0
Ohhh I get it now thanks Volodymyr2004 293 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

You can't find out who pressed a gui since that gui is only in the players gui. This code basically shows how to use this.

local target = game.Players.LocalPlayer
local owner = "Spooksletsky"

script.Parent.MouseButton1Down:connect(function()
    if target and target.leaderstats.Money.Value >= 100 and target.Name == owner then
        target.leaderstats.Money.Value = target.leaderstats.Money.Value-100
    end
end)
Ad

Answer this question