I have a little conflict with scripts, I recently put a script on my game that allows to extend the respawn time, but the problem is that this script uses this :
game.Players.CharacterAutoLoads = false
this is what allows the script to choose when to reappear, but the problem is that another one of my scripts conflicts and displays this error
23:08:27.845 - Workspace.SONIC.StatusChasing.Attack:40: attempt to index field'Character' (a nil value)
here is the line of code that is causing the problem :
for i,v in pairs(game.Players:GetChildren()) do local range = (v.Character.HumanoidRootPart.Position - Torso.Position).magnitude
any suggestions ?
What are you doing to extend respawn time?
A better way than messing with the AutoCharacterLoads is using the Died event from a Humanoid. If you have the player defined then you can load their character at any time using :LoadCharacter()
.
--After 5 seconds, the player character will load. humanoid.Died:Connect(function() wait(5) player:LoadCharacter() end)
You can have this in a PlayerAdded event function that will give you the player.
As for the second code piece provided. You should use :GetPlayers()
over the children method.
for i,v in pairs(game.Players:GetPlayers()) do --Only our players would be acquired in player service. print(v.Name) end