Badge script not working

  1. What do you want to achieve? A script that awards a badge when you touch a part, but i want it to stay as one script so its neat. (I did not make this script, it is part of a bigger system & everything is parented correctly and such)

  2. What is the issue? The issue is that the script will not work, and i’ve tried multiple different things.

  3. What solutions have you tried so far? I have tried debugging it with print statements, it says it awards the badge and it’s using the correct ID. I’ve tried testing it in the published place off studio, i’ve confirmed the badges are working and I dont have them in my inventory, and i’ve tried fixing the script in different ways.

for i,v in pairs(workspace.ToFind:GetChildren()) do
	if (v:IsA("BasePart")) then
		v.Touched:Connect(function(hit)
			if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
				local getplayer = game.Players:GetPlayerFromCharacter(hit.Parent)
				if getplayer then
					local profile = Profiles[getplayer]
					if profile.Data.Find[v.Name] == false then
						profile.Data.Find[v.Name] = true
						profile.Data.Items += 1
						local badgeid = 0
						if game.ReplicatedStorage.ConfigurationFolder.EnableBadges.Value == true and v.Configuration:FindFirstChild("BadgeID") and v.Configuration.BadgeID.Value >= 1 then
							badgeid = v.Configuration.BadgeID.Value
							task.spawn(function()
						if not BadgeService:UserHasBadgeAsync(getplayer.UserId, badgeid) then
							BadgeService:AwardBadge(getplayer.UserId, badgeid)
								end
							end)
						end
1 Like

Also, the script works on my game under my account but now that im doing it under a group it stopped working

Quick question, is the runcontext server?

It is set to legacy, tho the script is now magically working for some reason