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

How can I check if a player has already clicked a button before?

Asked by 8 years ago

Is it possible to check if a player has already clicked a button? Like if a player has already went through the Surface GUI and got something and then when they click it again they wouldn't be able to.

0
On a Surface GUI you carnt find the player, there are a lot of question on this forum relating to this. You might be able to do somthing localy with FE enabled http://wiki.roblox.com/index.php?title=Local_parts User#5423 17 — 8y

2 answers

Log in to vote
0
Answered by
alibix123 175
8 years ago

You could insert a BoolValue into the player (or the SurfaceGui but I'm not sure if this is a good idea) to check if the button has been clicked before. http://wiki.roblox.com/index.php?title=API:Class/BoolValue

Ad
Log in to vote
0
Answered by
DevNetx 250 Moderation Voter
8 years ago

The best way to do this would be to place the surfacegui into StarterGui. That way, you can track which player clicked it. An example:

LocalScript inside surfacegui:

script.Parent.Adornee = workspace.GuiPartExample

Then, to check if the player has already clicked it, you can insert a value into the player! Example inside a localscript:

local plr = game.Players.LocalPlayer
script.Parent.Button.MouseButton1Down:connect(function()
    if not plr:FindFirstChild('ClickedButton') then
-- do stuff
local value = Instance.new('BoolValue',plr)
value.Name = 'ClickedButton'
end)
0
The LocalScript doesn't make anything visible that's the problem. BennyBoiOriginal 293 — 8y
0
If you want, I could create an example place? DevNetx 250 — 8y

Answer this question