XaGuest
(XaGuest)
September 19, 2024, 2:42am
#1
I’m trying to make something that when a player reaches 250 candies, they get a badge but it isn’t working right now and I don’t know how to fix it!
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local Slaps = Instance.new("IntValue", leaderstats)
Slaps.Name = "Slaps"
Slaps.Value = 1000000
local Glove = Instance.new("StringValue", leaderstats)
Glove.Name = "Glove"
Glove.Value = "Default"
local candyz = Instance.new("IntValue", player)
candyz.Name = "Candy"
candyz.Value = 0
if candyz.Value >= 1 then
print(player.Name.. "has got 250 candy!")
game:GetService("BadgeService"):AwardBadge(player.UserId, 1302136441780953)
end
end)
Please help me try to fix the badge.
What do you mean it isn’t working right now?
Does the print(player.Name.."has got 250 candy!")
output?
Are you testing it in game or in studio?
The issue is that you are setting the value to 0, then immediately checking if it’s more than 1 (which is always going to be false).
Where are you changing the amount of candy?
XaGuest
(XaGuest)
September 19, 2024, 2:58am
#5
I’m changing it using the collectibles.
I’m just going to assume that you are changing the value in it at some point.
Try replacing
if candyz.Value >= 1 then
print(player.Name.. "has got 250 candy!")
game:GetService("BadgeService"):AwardBadge(player.UserId, 1302136441780953)
end
with
candyz.Changed:Connect(function()
if candyz.Value >= 1 then
print(player.Name.. "has got 250 candy!")
game:GetService("BadgeService"):AwardBadge(player.UserId, 1302136441780953)
end
end)
XaGuest
(XaGuest)
September 19, 2024, 3:03am
#7
Thank you so much for helping me!
system
(system)
Closed
October 3, 2024, 3:04am
#8
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.