Hello. I have this spectate script and I'm trying to fix a certain part of this script where the camera doesn't focus back on the player after they die and respawn. The problem is I can't seem to make CharacterAdded work.
Here's the part of the script:
playerList[position].CharacterAdded:Connect(function(char) --repeat print("test") updateCamera(playerList[position]) --until char.Humanoid.Health ~= 0 end)
I already tried fixing it by creating a name string for the player but it still didn't work.
It looked something like this:
local playerName = playerList[position].Name game.Players.playerName.CharacterAdded:Connect(function(char) --repeat print("test") updateCamera(playerList[position]) --until char.Humanoid.Health ~= 0 end)
You can't do Players.playerName as it will look for something named playerName. You need to do
game.Players[playerName].CharacterAdded:Connect(function(char)
Please use output for these types of issues, as your script would have errored and told you "playerName is not a valid member of workspace"