I have this badge that gives the player the Teddy Bloxpin gear, but they have to rejoin to get it. How do I make it so they get the gear as soon as they get the badge, and keep it if they die?
ServerScriptService:
local mps = game:GetService("BadgeService")
local badge_id = 2127257301
game.Players.PlayerAdded:Connect(function(player)
if mps:UserHasBadgeAsync(player.userId, badge_id) then
game.ServerStorage.TeddyBloxpin:Clone().Parent = player:WaitForChild("Backpack")
game.ServerStorage.TeddyBloxpin:Clone().Parent = player:WaitForChild("StarterGear")
end
end)
game.ReplicatedStorage.TeddyBloxpin.OnServerEvent:connect(function(player)
game.ServerStorage.TeddyBloxpin:Clone().Parent = player:WaitForChild("Backpack")
game.ServerStorage.TeddyBloxpin:Clone().Parent = player:WaitForChild("StarterGear")
end)
Gives Badge:
local badgeservice = game:GetService("BadgeService")
local id = (2127257301)
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)
local mps = game:GetService("BadgeService")
script.Parent.Touched:connect(function(plr)
local player = game.Players.LocalPlayer
end)

4 comments
I get this error: Workspace.Model.Model.SecretRoom.Part.Script:21: attempt to index nil with 'Backpack'
"player" is nil because it's not defined. Just change it to "plr"
It works, but it gives a million of them filling the player's inventory
Check if the player already owns the badge so it won't fill the entire inventory.