I want to give the player a badge when they touch a part.
I have tried so far 4 scripts and they don’t work. This is a huge problem now because I have to create a topic about this more than once in order to get any replies. I think this could be a bug or glitch but I’m not sure. I do not own the badge already, API access is enabled, badge is active, player can touch the part, the script is under the right part, but it won’t award the badge AT ALL.
I looked here many times but nothing worked. I am desperate to find a solution to this. I can’t understand why it won’t work. Somebody tested one of my scripts and it worked for them, so why won’t it work for me? I don’t want to go through the same 2 week process where I tried to figure out how to make cutscenes in one of my games. I just want to find out why this isn’t working an fix it. I wish I could get some in depth help on this.
I used these scripts:
Script 1:
local BadgeService = game:GetService("BadgeService")
local id = 2140926703
local badgegive = script.Parent
badgegive.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if not BadgeService:UserHasBadgeAsync(plr.UserId, id) then
BadgeService:AwardBage(plr.UserId, id)
end
end
end)
Script 2:
local Players = game:GetService("Players")
local part = script.Parent
local badgeService = game:GetService("BadgeService")
local badge = 2140926703
part.Touched:Connect(function(hit)
local player = Players:GetPlayerFromCharacter(hit.Parent)
if not player then
return
end
local hasBadge = badgeService:UserHasBadgeAsync(player.UserId, badge)
if hasBadge then
print( player.Name .. " owns this badge!")
else
badgeService:AwardBadge(player.UserId, badge)
end
end)
Script 3:
local badgeservice = game:GetService("BadgeService")
local id = 2140926703 -- Your badge ID here
-- Part touched
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid")then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
badgeservice:AwardBadge(plr.UserId,id)
end
end)
Script 4 (tested in my testing game):
local badgeService = game:GetService("BadgeService")
local id = 2140974247
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
badgeService:AwardBadge(plr.UserId, id)
end
end)
I am worried that I could get warned or something for making so many topics like this but I am desperate for a solution. I have never been able to award badges on touch when I have tried in the past. I decided not to try and award a player a badge when they touch a part for a while because it would never work. Now I really want to have a badge for every stage/level the player completes in my game. I really hope somebody can give me a solution. I don’t want to make a bunch of topics but I need to in order to get replies. I want this nightmare to end. I want to figure out how to award a player a badge when they touch a part. I cannot continue working on the game easily without this.
All I ask is that, please, please, please, somebody out there, with knowledge on this, and somebody who knows exactly what might be wrong, somebody who can help me with this, gives me the solution to why this isn’t working.