How would I edit the classic sword script to solve this issue?

Only use the CharacterAdded event. Try Players[i].Character:MoveTo(vector3) instead of setting the CFrame maybe but its weird that it would freeze them. I’m not sure

2 Likes

turns out the event is only firing the first time i die. it actually doesnt matter whether I reset or die from a kill block now?

2 Likes

the event will only fire once any help?

2 Likes

just use a connection.

local respawnConnection

function characterAdded(character)
   --code
   respawnConnection:Disconnect()
   respawnConnection = players[i].CharacterAdded:Connect(characterAdded)
end

respawnConnection = players[i].CharacterAdded:Connect(characterAdded)
2 Likes

I don’t understand what you mean by that, but why exactly does this event only run once?

image

2 Likes

because, you’re setting the player’s character to another character, and never changing the connection to the new character so the event only fires for the old character

2 Likes

Oh great explanation. Is there a simple fix for that besides connections though, because I don’t quite under that.

1 Like

Actually i do understood what the connections mean. You really helped me sir, thank you. :blush:

1 Like

I understood when i saw you reconnected it to the character added right after the disconnect in the post above. You just made me learn a useful new concept ty!

2 Likes

glad to hear you understand it. using connections:

local deathConnection

local hum = players[i].Character.Humanoid
function died()
   players[i]:LoadCharacter()
   hum.Health = 100
   --whatever this line is, can't see it
   players[i].Character.Parent = workspace.GameSystem.playersInGame
   print("teleported?")

   hum = players[i].Character:WaitForChild("Humanoid")

   deathConnection:Disconnect()
   deathConnection = players[i].Character.Humanoid.Died:Connect(characterAdded) --set the event for the new character
end

deathConnection = hum.Died:Connect(died) --for the old character
2 Likes

Wow i understand that (like just now), but never would have figured it out on my own even if i understood connections. You seem smart lol and im a bit intimidated now lol.

2 Likes

Bruh i still dont get this. What function do i add in the characterAdded spot?

1 Like

What do you mean by set the event for the new character there?

1 Like

when you respawn the character, the game automatically sets the new character, which will be the ‘new character’

1 Like

do you not have a characteradded event?

1 Like

Wait? But why would i establish a connection to an event? I thought you can only connect to functions?

Ohh did you want me to right the characterAdded function above cus that would make more sense.

the connection is the event and the function combined.

so when an event is called, the function gets called too.
the connection is variable for it

Yes i understand, but I didn’t realize at first that i had to make the respawn connection too sorry!

that is alright, that was the first example that made you understand connections completely new anyway