I need help with a gui script

Hello, I would like some help basically I’m working on a game like find the markers and I would like it to do the same thing that when you touch a marker it shows a gui but when you touch it again it doesn’t show it but for me it would be clicking it so the only problem I got is making it that when you click it the first time it shows the GUI only for that player and when you click it again it doesn’t show a gui.

Any help is appreciated.


So you want to show a UI when you click a part?

1 Like

So if you want to make a UI visible with a script, do the following

  1. Make a StarterGui with a ScreenGui and e.g. a frame
  2. Insert a part into workspace and insert a ClickDetector and a script
  3. Insert the following script:

I hope this will help you!

1 Like

That did help me alot but how would I make it that when you click the block again the GUI doesn’t show like after you got the badge and you click it again the GUI doesn’t show.


Type script:Destroy() on line 5

You can delete ClickDetector after Click!

The problem on this is that if you join the game again, you can click the gui again. For this you have to add a function (add a script into serverscriptservice). Because you got awarded a badge u can use the UserGotBadgeAsync function to check if the player got the badge. If he got the badge, you just simply destroy the part.

1 Like

What happen if he not going to give Badge?
Then he need DataStoreService

Can you explain a bit further? He said in his second post, that after you got the badge it should not appear again…

Oh that’s my mistake. sorry lol


local BadgeService = game:GetService("BadgeService")
local BadgeId = 0 -- replace with badge ID
  local hasBadge

  local success, errMsg = pcall(function()
    hasBadge = BadgeService:UserHasBadgeAsync(game.Players.LocalPlayer.UserId, BadgeId)
if success and hasBadge ~= true then
 game.ReplicatedStorage.FoundMarker:FireServer(BadgeId) -- Because Badge cannot be awarded in client


local BadgeService = game:GetService("BadgeService")
 BadgeService:AwardBadge(player.UserId, BadgeId)

Must need RemoteEvent called ‘FoundMarker’ in ReplicatedStorage.

I already got a script that gives the badge all I need is that if they got the badge and they click it again it doesn’t show the GUI and it doesn’t destroy the block cuz it’s 10 per server.

Then you don’t have to award badge in this script?

We can’t detect player own badge if player didn’t join again after Award Badge.
So you have to destroy Click Detector after award.[You Must Destroy Click Detector in LocalScript!] and If player rejoin, Script will find player own badge. Then you can also destroy Click Detector of marker that player owns.

But it will destroy it for everyone on that server I just need it only for that player.

Then Destroy in LocalScript. Maybe work!

You can check if a player owns a badge by using UserHasBadgeAsync().
In your case it would look like this:

A script in serverscriptservice;

	local success, hasBadge = pcall(function() --/ We use pcall to make sure the script doesn't stop working if there's an error.
		return BadgeService:UserHasBadgeAsync(plr.UserId, badgeID)
	if not success then
		print("error while checking if user owns badge")
	if hasBadge then
		event:FireClient(plr, badgeID)

A localscript inside StarterGui/StarterPlayerScripts

local clickdetector = game.Workspace.ClickDetector

	if badgeID == ur badge id then
		clickdetector:Destroy() --/ Will only destroy for the client because it's inside a localscript.
1 Like


If you want to achieve that, as @IamProtectingPeople said, you should use UserHasBadgeAsync() if you want to check if the player got the badge whenever the player joins the game.

to show the gui, make a screengui in the StarterGui and then in your MainScript parent it to the PlayerGui. And then, make it visible with:

ScreenGui.Enabled = true

also, you need to make an If conditional and the UserHasBadgeAsync() method to check if the player got the badge, and if he does, then you fire a remote event to the client and change the MaxActivationDIstance propertie of the ClickDetector to 0.

Hope it helps! :smile: