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

Shop-type GUI not prompting a purchase/checking purchase?

Asked by 7 years ago

I have a GUI that sells a t-shirt and gives the player a tool if they buy/own the shirt

In one of the buttons, I've put in this LocalScript:

id = 826251512
player = game.Players.LocalPlayer
a = game.ServerStorage.Tool
b = a:Clone()

owned = (
    game:GetService('BadgeService'):UserHasBadge(player.userId, id)
    )

function givetool()
    if player ~= nil then
    local tool = b:Clone()
    tool.Parent = player.Backpack
    end
end

script.Parent.MouseButton1Click:connect(function()
    if not owned then
        game:GetService("MarketplaceService"):PromptPurchase(player, id)
    elseif owned then
        givetool()
    end
end)

For reference, I guess: - A tool is located in ServerStorage called "Tool" -The GUI is given to the player when they touch a brick (this part works)

In game, when I click the button it's supposed to: - Check if the player owns the Item then - Give the player the tool

However, in the game, - The GUI doesn't do anything when clicked - I get this in the Client Log: "ServerStorage is not a valid member of DataModel"

Help?

(I'm fairly new at trying more complicated scripts so if you could explain where I went wrong and why that'd be amazing)

1 answer

Log in to vote
0
Answered by 7 years ago

Local Scripts cannot access Server Storage. You can use Replicated Storage instead.

0
Thanks for your help! Robloxian1092 0 — 7y
Ad

Answer this question