Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Unable to cast instance on int value

Asked by
TomsGames 225 Moderation Voter
10 years ago
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

Log in to vote
4
Answered by
Merely 2122 Moderation Voter Community Moderator
10 years ago

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

if b:UserHasBadge(p.userId, badges[i]) then
0
Thanks mere-dog. TomsGames 225 — 10y
Ad

Answer this question