✓ Accepted answer
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
end
else
print("No GPID")
end
end
end)
1 comment
If there is an output, please post it.