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

Unable to cast value to object?

Asked by
Oficcer_F 207 Moderation Voter
5 years ago
Edited 5 years ago

Why doesn't this work? And why am I getting this error? ERROR AT LINE 13

GamePassService = game:GetService('MarketplaceService')
toolGamePass = 2068240



script.Parent.Touched:Connect(function(hit)
    player = game.Players:GetPlayerFromCharacter(hit.Parent)

    if GamePassService:UserOwnsGamePassAsync(player.UserId,toolGamePass) then

    hit.Parent:MoveTo(Vector3.new(0,100,0))
    else
                GamePassService:PromptGamePassPurchase(player.UserId, toolGamePass)

end





end)

Error:

Unable to cast value to Object

1 answer

Log in to vote
1
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
5 years ago

Because you passed an int, when it's supposed to a player object.

Fixed line:

GamePassService:PromptGamePassPurchase(player, toolGamePass)
0
Thanks man! Oficcer_F 207 — 5y
Ad

Answer this question