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 value to object?

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

✓ Accepted answer

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

Fixed line:

GamePassService:PromptGamePassPurchase(player, toolGamePass)

1 comment

0

Thanks man!

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