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? Unsure what this error means?

Asked by 5 years ago

Basically, this script should prompt you if you don't own a game pass id and if you do it will change a value in workspace. Unsure what this error means? Here is the code:


local id = 5242880 local UserId = game.Players.LocalPlayer.UserId script.Parent.MouseButton1Click:Connect(function() game:GetService("MarketplaceService"):PromptGamePassPurchase(UserId, id) script.Parent.Parent.Status.Text = "In order to be a Middle rank you need to buy the gamepass." if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(UserId,id) then game.Workspace.Middle.Value = true else wait(7) script.Parent.Parent.Status.Text = "" end end)
0
Where is the script located? EliteRayGawnX2 124 — 5y

1 answer

Log in to vote
1
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
5 years ago

PromptGamePassPurchase requires a Player as its first argument, as you can see here - PromptGamePassPurchase on the wiki, and checking the UserOwnsGamePassAsync should be done on the server

0
Well said. DaggerOf_Fly -24 — 5y
0
good job User#19524 175 — 5y
Ad

Answer this question