I don’t know how to fix this simple trophy win system. Issue is with the badge, it wont award the badge but it does teleport the player. I would also appreciate anyone making the script more optimized.
Script:
local hitbox = script.Parent
local BS = game:GetService("BadgeService")
local offset = Vector3.new(0, 2, 0)
hitbox.Touched:Connect(function(hit)
if hit.Parent.Humanoid then
local Humanoid = hit.Parent.Humanoid
local char = hit.Parent
local plr = game.Players:GetPlayerFromCharacter(char)
local hrp = char.HumanoidRootPart
BS:AwardBadge(plr.UserId, '3851921246732032')
hrp.CFrame = game.Workspace.SpawnLocation.CFrame + offset
end
end)
local hitbox = script.Parent
local BadgeService = game:GetService("BadgeService")
local offset = Vector3.new(0, 2, 0)
local badgeId = 3851921246732032
function onHit(hit)
if hit.Parent:FindFirstChildOfClass("Humanoid") then
local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
BadgeService:AwardBadge(player.UserId, badgeId)
local hrp = hit.Parent:FindFirstChild("HumanoidRootPart")
if hrp then
hrp.CFrame = game.Workspace.SpawnLocation.CFrame + offset
end
end
end
end
hitbox.Touched:Once(onHit)
Explanation, badgeId (the second passed parameter in AwardBadge) requires a number integer value. You passed a string value.
Read more here: BadgeService#AwardBadge