Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Unable to cast instance on int value

b = game:GetService("BadgeService")
badges = {150952884}

for i = 1, #badges do
	if b:UserHasBadge(p, badges[i]) then
		local s = Instance.new("StringValue", servstat)
		s.Name = tostring(badges[i])
	end
end

This script returns the error "Unable to cast instanec on int value" on line 5.

This is not the whole script.

It is part of a playeradded script, p is the player.

What am I doing wrong?

1 answer

✓ Accepted answer

BadgeService:UserHasBadge's first argument is the userId, not the player.

if b:UserHasBadge(p.userId, badges[i]) then

1 comment

0

Thanks mere-dog.

This discussion is preserved as it was. New answers, comments, and votes are closed.