Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

1 comment

0

Thanks for your help!

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