I have a game, where if the person is VIP and wins a round, it will give them their points, which is more than regular players. Though I am having an error come out in the output. 'Unable to cast to Object' on line 8. I'm not sure what this means or how to fix it. Any help is appreciated, thanks.
Edit: I have now solved this, I did this by changing line 8 to
if game:GetService("GamePassService"):PlayerHasPass(game.Players[v], gamepassId) then
Code:
local gamepassId = 1109268370
local gemsOnWin = 10
local vipWin = gemsOnWin * 1.5
for i,v in pairs(_G.playersInGame) do
if v ~= nil then
status.Value = v..' is the winner!'
if game:GetService("GamePassService"):PlayerHasPass(v, gamepassId) then
game.Players[v].leaderstats.Gems.Value = game.Players[v].leaderstats.Gems.Value + vipWin
game.Players[v]:
else
game.Players[v].leaderstats.Gems.Value = game.Players[v].leaderstats.Gems.Value + gemsOnWin
game.Players[v]:LoadCharacter()
break
end
end
end

6 comments
have you tried print debugging?
Printing out values is the best way to find out what's going wrong.
I did printing, and it stopped at line 8. That's what was getting the error.
Im guessing that v is a string? if so then PlayerHasPass requires the player object not a string which would explain the error.
try using :PlayerHasPass(game.Players[v], gamepassId)
I literally just found that out myself haha. Thanks though.