Hey I need this script to work when the player enters the game but its only working when they respawn. How to I get it to work when they enter. I have tried a couple different things but its not working. Any help is appreciated. Thank you
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)
Revised code
GPS = game:GetService("GamePassService")
game.Players.PlayerAdded:connect( function(player)
print("it worked")
local player = game.Players:FindFirstChild(player.Name)
player.CharacterAdded:connect(function(character)
print("Respawned")
if player:FindFirstChild("Head") ~= nil then
print("It's a Player!")
if GPS:PlayerHasPass(player, gpid) then
print("Has GPID")
for i = 1,#tools do
game.ServerStorage.GamepassWeapons:FindFirstChild(tools[i]):Clone().Parent = player.Backpack
end
else
print("No GPID")
end
end
end)
end)

1 comment
try using game.Players.PlayerAdded:Connect(respawned)