wait(2) gpid = 1 -- Gamepass ID here. tools = {"tool1", "tool2", "tool3"} -- Put the tools in Lighting, and their names here. GPS = Game:GetService("GamePassService") function respawned(char) player = game.Players:FindFirstChild(char.Name) print("Respawned") if char:FindFirstChild("Head") ~= nil then print("Player") if GPS:PlayerHasPass(player, gpid) then print("Has GPID") for i = 1,#tools do game.Lighting:FindFirstChild(tools[i]):Clone().Parent = player.Backpack end else print("No GPID") end end end game.Workspace.ChildAdded:connect(respawned)
In the future if you just want to know if something will work, just test it rather than coming here
This would work only if the Child that entered the workspace was a player - otherwise it would error.
To make this error-proof, use a PlayerAdded
event with a CharacterAdded
event.
Also, I suggest you use the PlayerOwnsAsset method, as it returns live results from the website while the PlayerHasPass
method returns cached results - meaning that you'd have to rejoin the game if you were to buy the gamepass in game.
Additionally, Lighting shouldn't be used for storage - I suggest using ServerStorage.
This script should be in workspace;
--Put your gamepass ID here local assetId = 000000 -- Put the tools in ServerStorage, and their names here. local tools = {"tool1", "tool2", "tool3"} local ms = game:GetService('MarketplaceService') function giveTools(plr) if ms:PlayerOwnsAsset(plr,assetId) then for i = 1,#tools do local tool = game.ServerStorage:FindFirstChild(tools[i]) if tool then if not plr.Backpack:FindFirstChild(tool.Name) then tool:Clone().Parent = plr.Backpack end end end end end game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(char) giveTools(plr) end) end)