I’m made script that is supposted to give badge on clicking model 5 times. For some reason when i click it 5 or more times it doesnt do anything. Tryed to looking for solution on devforum didnt found anything…
-- LocalScript
local ClickDetector = script.Parent.Clicker
local ClicksVal = script.Parent.ClicksValue
local BadgeService = game:GetService("BadgeService")
local BadgeID = 4154011418
print("Badge awarding loaded i hope it works..")
if ClicksVal.Value == 5 then
game.Players.PlayerAdded:Connect(function(Player)
BadgeService:AwardBadge(Player.userId, BadgeID)
print("Giving badge wait...")
end)
end
--Script
local BadgeService = game.BadgeService
local ClickDetector = script.Parent.Clicker
local ClicksVal = script.Parent.ClicksValue
ClickDetector.MouseClick:Connect(function()
ClicksVal.Value += 1
end)
You are only firing the if statement once, since it didnt return true, nothing will happen, try this:
function CheckClicks(p: Player, Badge: number?) -- function with 2 Args
if ClicksVal.Value >= 5 then -- Checks Value
BadgeService:AwardBadge(p.UserId, Badge) -- Awards Badge
return true
else
return false
end
end
game.Players.PlayerAdded:Connect(function(Player)
if CheckClicks then
BadgeService:AwardBadge(Player.userId, BadgeID)
print("Giving badge wait...")
end
end)
ClickDetector.MouseClick:Connect(function(Player) -- Gets Player who Clicked
ClicksVal.Value += 1 -- Adds Click
CheckClicks(Player, 4154011418) -- Fires with provided Args
end)
Badges are Server Sided only and Can only be Awarded through a ModuleScript and a Regular Script, They can only be fired on the Client by using a RemoteEvent
Nvm there were a couple of lines that needed to be removed to fix your script!
-- Script
local ClicksVal = script.Parent.ClicksValue
local BadgeService = game.BadgeService
local ClickDetector = script.Parent.Clicker
local BadgeID = 2129894181
ClickDetector.MouseClick:Connect(function(Player) -- Gets Player who Clicked
ClicksVal.Value += 1 -- Adds Click
CheckClicks(Player, 2129894181) -- Fires with provided Args
end)
function CheckClicks(p: Player, Badge: number?) -- function with 2 Args
if ClicksVal.Value >= 5 then -- Checks Value
BadgeService:AwardBadge(p.UserId, BadgeID)
print("Giving badge wait...")
else
print("Here is your badge!")
end
end