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

Help making a script for a gear get script if u have a gamepass?

Asked by 4 years ago

Hello! So I am trying to make a script like in Jailbreak SWAT team, so if you click the gun. at a wall then if u do not own the gamepass then you do not get it in your inventory if you do u go it.

I am a beginner scripter and I tried doing this, if you can help me please write. Thanks.

local gamepassId = 11378351 local tool = game.ReplicatedStorage:FindFirstChild("The Little Friend"):Clone()

script.Parent.ClickDetector.MouseClick:Connect(function(player) if gamepassId:UserOwnsGamePassAsync(player.UserId, gamepassId) then tool.Parent = player.Backpack for _,two in pairs(tool:GetChildren()) do if two:IsA ("LocalScript") then two.Disabled = false
wait()
else print(2) end end end end)

1 answer

Log in to vote
0
Answered by
zane21225 243 Moderation Voter
4 years ago

Firstly, please use the appropriate buttons when making your question.

For example, you can show your code via the tiny "Lua" button.

print("Hello world!")

Anyways, let me fix up your script.

Firstly, :UserOwnsGamePassAsync is not a valid member of Player. Instead, you'll need to reference the MarketplaceService.

Below is the script I whipped up for you.

--[[
INSTRUCTIONS:
1) Replace "10944044" with your Game Pass ID
2) Insert the tool of your choice into ServerStorage (Game > ServerStorage)
3) Change the "ClassicSword" to the name of your Tool.
4) If you'd like the tool to be auto-equipped, change the "false" on line 12 to a "true"
]]

-- Variables:
local marketplaceService = game:GetService('MarketplaceService')

local gamePassId = 10944044
local gamePassTool = game:GetService('ServerStorage').ClassicSword
local autoEquipTool = false

-- Scripting:
game.Players.PlayerAdded:Connect(function(player)
    if marketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassId) then
        if autoEquipTool == false then
            gamePassTool:Clone().Parent = player.Backpack
        elseif autoEquipTool == true then
            gamePassTool:Clone().Parent = player.Character
        else
            warn('The autoEquipTool variable must be set to true/false.')
        end
    end
end)
0
You can click the little 'view source' button (appears when you hover over the code) to copy it. zane21225 243 — 4y
Ad

Answer this question