Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you find out who clicked an Image button?

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!

3 comments

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.

0

So I just do- if script.Parent.Value==LocalPlayer then -then it will go on?

0

Ohhh I get it now thanks

1 answer

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.