Quick overview! (I'm a fairly new to scripting, please bare with me!)
I have a GUI and a game pass, the idea is to have the player click the txt button and they get the tool whether they have the game pass or not, if not. Then they get prompted the game pass. But I cant seem to get it to work, and I've tried everything I know. So I'm here now.
This is the Local script inside the txt button for the game pass tool
local toolid = 13191691
local RE = game.ReplicatedStorage.RemoteEvent
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
script.Parent.MouseButton1Click:Connect(function(plr)
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, toolid) then
RE:FireServer("ToolOwned")
else
local function romptPurchase()
local player = Players.LocalPlayer
MarketplaceService:PromptProductPurchase(player, toolid)
end
end
end)
The problem with that is I keep on getting attempt to index nil with 'UserId' on line 7
Server script:
local RE = game.ReplicatedStorage.RemoteEvent
RE.OnServerEvent:Connect(function(plr, state)
if state == "ToolOwned" then
local tool = game.ReplicatedStorage.Weapons.KITCHEN
local Clonedtool = tool:Clone()
Clonedtool.Parent = plr.Backpack
end
end)
Constructive criticism greatly apricated! This is my first time asking a question here, so I'm sorry if I did something wrong.

1 comment
Your
playervariable doesn't exist. I'm assuming you're referring to the variable passed to the function on line 6:plr. Replaceplayerwithplrand your script should run how it's intended to.