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

How to make a gamepass give someone a weapon or weapons if they have it?

This is useful for like minigames and stuff! So if you know how please help me.

2 answers

Hello if you want to do that make a model and insert a script and type ~~~~~~~~~~~~~~~~~

local function WaitForChild(parent, childName) assert(parent, "ERROR: WaitForChild: parent is nil") while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end return parent[childName] end


--| Variables |--

local GamePassService = Game:GetService('GamePassService') local PlayersService = Game:GetService('Players') local LightingService = Game:GetService('Lighting') --TODO: Use new data store service once that exists

local GamePassIdObject = WaitForChild(script, 'GamePassId') local AdminTools = WaitForChild(LightingService, 'Gamepack1')


--| Functions |--

-- Makes copies of all the admin tools and puts them in target local function CloneAdminTools(target) for _, tool in pairs(AdminTools:GetChildren()) do local toolClone = tool:Clone() toolClone.Parent = target end end

-- When a player with the game pass joins, give them the admin tools local function OnPlayerAdded(player) if GamePassService:PlayerHasPass(player, GamePassIdObject.Value) then local starterGear = WaitForChild(player, 'StarterGear') CloneAdminTools(starterGear) if player.Character then -- They've already loaded and won't get their StarterGear until next spawn local backpack = WaitForChild(player, 'Backpack') CloneAdminTools(backpack) end end end


--| Script Logic |--

PlayersService.PlayerAdded:connect(OnPlayerAdded)

once you have this insert a IntValue and rename it to GamePassId and change the value to the game pass id then add a model into the model and name it Gamepack1 and put the weapons in the model called Gamepack1.

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