I am using a local script and tried to access MarketPlaceService, but it continues to say error. Before it stated that there was an unknown player, which i attempted to fix by adding the .Parent 7 times, until it reached workspace, but it still seems to be giving errors. The following is the one im encountering:
MarketplaceService:PromptPurchase() player should be of type Player, but is of type nil
I don't understand. Please help?
local purchase = script.Parent.Parent:WaitForChild("PurchaseButton") purchase.MouseButton1Click:connect(function (player) local Id = script.Parent.Text -- typed in ID print("id taken") game:GetService("MarketplaceService"):PromptPurchase(script.Parent.Parent.Parent.Pare nt.Parent.Parent.Parent:GetChildren(player),Id) end)
I'm afraid I might have to use script instead of LocalScript, which is what i'm currently using, but i have no idea. Any thoughts?
The problem isn't because it's a local script. It's because :PromptPurchase() needs the Player object, not the character, otherwise you get that error.
Since it's the local player clicking their local purchase button then define the LocalPlayer at the top.
local player = game.Players.LocalPlayer local purchase = script.Parent.Parent:WaitForChild("PurchaseButton") purchase.MouseButton1Click:connect(function() local Id = script.Parent.Text -- typed in ID print("id taken") game:GetService("MarketplaceService"):PromptPurchase(player, Id) end)