[FIXED]Gear giver gamepass scripting help

So I’m trying to make a button that prompts you when you click it.

This is the script for the button

local mps = game:GetService("MarketplaceService")

local gamepass_id = 9141220

script.Parent.MouseButtonClick:connect(function(

local player = game.Players.LocalPlayer

mps:PromptGamePassPurchase(player, gamepass_id)

end)

mps.PromptGamePassPurchaseFinished:connect(function(player, id, purchased)

if id == gamepass_id and purchased then

game.ReplicatedStorage.Give.Fireserver()

end

end)

This is the script in server script storage

local mps = game:GetService("MarketplaceService")
local gamepass_id = 9141220

game.Players.PlayerAdded:Connect(function(player)
	if mps:UserOwnsGamePassAsync(player.UserId. gamepass_id) then
		game.ServerStorage.Sniper3:Clone().Parent = player:WaitForChild("Backpack")
		game.ServerStorage.Sniper3:Clone().Parent = player:WaitForChild("StarterGear")
	end
end)


game.ReplicatedStorage.Give.OnServerEvent:Connect(function(player)
		game.ServerStorage.Sniper3:Clone().Parent = player:WaitForChild("Backpack")
		game.ServerStorage.Sniper3:Clone().Parent = player:WaitForChild("StarterGear")
end)

You should consider wrapping your code around the following mark up technique:
3 `s followed by lua.

image

print("Hello, World!")

It would help developers analyse your code easier.

1 Like

Isn’t it supposed to be

script.Parent.MouseButtonClick:Connect(function() -- the brackets

and is your button a brick with a clickDetector or a gui button?

Is this button on the GUI or in the Workspace? Also, what is your issue? You are providing no information on any errors.