UserId is not a valid member of Part "Workspace.Jai_2den.Right Leg
local part = game.Workspace.Lobby.Spleef.Badgegiver
local badgeid = 2149792693
local badge = game:GetService("BadgeService")
part.Touched:Connect(function(player)
print("Floor touched")
if not badge:UserHasBadge(player.UserId, badgeid) then
badge:AwardBadge(player.UserId, badgeid)
print("Badge given")
end
end)
The issue you have is that you’re assuming every thing that touches the part is a player. For the most part, this wouldn’t be a problem as long as it’s hovering and there isn’t flying parts in your game, but if its a giant, invisible block, it may be touching some parts on the side.
The fix to this is to check if the part hit, which you’ve labelled “player” even though that isnt the case, is the player.
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = hit.Parent:FindFirstChild("Humanoid")
print("Floor touched")
if not badge:UserHasBadge(player.UserId, badgeid) then
badge:AwardBadge(player.UserId, badgeid)
print("Badge given")
end
end
end)
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
print("Floor touched")
if not badge:UserHasBadge(player.UserId, badgeid) then
badge:AwardBadge(player.UserId, badgeid)
print("Badge given")
end
end
end
end)