So basically, this script gives the owner (me) a tool from the lightning section, in there is a model called OwnerTools and a tool. The script works fine but.. when ever I die, I just lose the item and I have no idea how to fix this. The script:
game.Players.PlayerAdded:connect(function(player) if player.userId == game.CreatorId then player.CharacterAdded:wait() for i,v in pairs(game.Lighting.OwnerItems:getChildren()) do v:Clone().Parent = player.Backpack end end end)
-Thanks
See the roblox Wiki - CharactedAdded (event of the Player object) http://wiki.roblox.com/index.php?title=API:Class/Player/CharacterAdded
Okay ill help you out, so you could use a player died function like this
game:GetService('Players').PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() -- code here end) end) end)
So this is how your code would look
game:GetService('Players').PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() if player.userId == game.CreatorId then for i,v in pairs(game.Lighting.OwnerItems:getChildren()) do v:Clone().Parent = player.Backpack end) end) end)