Hello everyone, I made a badge when you touched it, it appears a GUI, but it seems to just give to the first player that touched, the second one can’t get it
this is the script inside of the brick you touch to get the badge and fire the GUI:
local id = 2128733046
local RS = game.ReplicatedStorage
deb = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if deb == false then
deb = true
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
badgeService:AwardBadge(plr.UserId, id)
if plr then
RS["ShowBadgeShower"]:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent))
end
end
end
end)
It looks like you forgot to set the deb to false after a certain amount of time. Try changing your code to something like this:
local id = 2128733046
local RS = game.ReplicatedStorage
deb = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if deb == false then
deb = true
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
badgeService:AwardBadge(plr.UserId, id)
if plr then
RS["ShowBadgeShower"]:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent))
end
wait(3)
deb = false
end
end
end)
Hi @BoidInternet_123, sorry it’s me again, I just remember why I just not used debounce, because it appears twice times when you touch the part, I mean the GUI, do you know how can I avoid this?
Did you try adjusting the debounce time (the time inside wait()) to something bigger than 3?
Alternatively you could check if the player already has the badge, if they do, don’t do the shower event. To check if a player has a badge, you can use badgeService:UserHasBadgeAsync().