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

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

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

✓ Accepted answer

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)

1 comment

0

You can click the little 'view source' button (appears when you hover over the code) to copy it.

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