if BS:UserHasBadgeAsync(player.UserId, VIPBadge_ID) then
AccessVIPRoom:FireClient(player)
elseif Tickets.Value >= price then
Tickets.Value = Tickets.Value - price
BS:AwardBadge(player.UserId, VIPBadge_ID)
AccessVIPRoom:FireClient(player)
else
warn(player.Name.." doesn't have enough Tickets to enter VIP")
end
This script is a VIP room script, and basically checks to see if the player has the badge or not to let them in. If they don’t have the badge, then they pay for it, via price, then get awarded the badge so they don’t need to pay for it again.
This portion of my script has no errors, but every time it runs, (no matter if I have the badge or not) still acts like I’ve never gotten the badge and ends up running the second part of the if statement. (it just takes my money every time)
I have no idea why this is happening…
Any help is appreciated!
Might be something wrong with the if statement order, so try this:
local success, badgeOwned = pcall(BS.UserHasBadgeAsync, BS, player.UserId, VIPBadge_ID)
if success then
if badgeOwned then
AccessVIPRoom:FireClient(player)
else
if Tickets.Value >= price then
local success, badgeAwarded = pcall(BS.AwardBadge, BS, player.UserId, VIPBadge_ID)
if success and badgeAwarded then
Tickets.Value -= price
AccessVIPRoom:FireClient(player)
else
warn(string.format("Error awarding badge to player %i (%s): %s", player.UserId, player.Name, tostring(badgeAwarded)))
end
else
warn(string.format("Player %i (%s) currently doesn't have enough tickets to enter VIP room", player.UserId, player.Name))
end
end
else
warn(string.format("Error getting badge ownership info for player %i (%s): %s", player.UserId, player.Name, tostring(badgeOwned)))
end