wait(2) gpid = 233549351 tools = {"The Beans"} GPS = game:GetService("GamePassService") function respawned(char) local player = game.Players:FindFirstChild(char.Name) print("Respawned") if char:FindFirstChild("Head") ~= nil then print("It's a 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)
Thanks!
There were three things that were potentially wrong here. 1: The name of the tool has a space 2: The connected function passes no arguments 3: (Not a real problem) Your code is not indented and it bothers me
Here is your code rewritten to address the second problem. I would strongly recommend that you use the ServerStorage service instead of Lighting.
wait(2) local gamePassID = 233549351 local PassService = game:GetService("GamePassService") local tools = {"The Beans"} function respawned(char) local player = game.Players:FindFirstChild(char.Name) print("Respawned") if char:FindFirstChild("Head") then print("It's a Player!") if PassService:PlayerHasPass(player, gamePassID) then print("Has GPID") for i = 1, #tools do local tool = game.ServerStorage:FindFirstChild(tools[i]):Clone() tool.Parent = player.Backpack end else print("No GPID") end end end game.Players.PlayerAdded:connect(respawned(char))
Or, if you wanted to, you could put all the tools in a folder (Model) inside the ServerStorage. This address both the first and second problem
wait(2) local gamePassID = 233549351 local PassService = game:GetService("GamePassService") local tools = game.ServerStorage.Tools:GetChildren() game.Players.PlayerAdded:connect(function(char) local player = game.Players:FindFirstChild(char.Name) print("Respawned") if char:FindFirstChild("Head") then print("It's a Player!") if PassService:PlayerHasPass(player, gamePassID) then print("Has GPID") for i, v in pairs(tools) do local tool = v:Clone() tool.Parent = player.Backpack --So much cleaner! :D end else print("No GPID") end end end)
There is nothing wrong I suggest that you name the tool "TheBeans" together like that and change the script where it says tools too = {"TheBeans"} then put the tool in Lightning must not be a model.