Twivvn
(Twivvn)
August 11, 2023, 7:19pm
#1
What do you want to achieve? I want the players character to teleport back to one of my teleports upon dying by a kill part or classic sword.
What is the issue? The event will only fire once.
What solutions have you tried so far? I do not know of any solutions just yet.
players[i].Character.Humanoid.HealthChanged:Connect(function()
if players[i].Character.Humanoid.Health == 0 then
print("health changed")
players[i].Character.Humanoid.Health = 100
print("health updated")
players[i].Character.HumanoidRootPart.CFrame = CFrame.new(workspace.GameSystem.Teleports["Part"..math.random(8)].Position)
players[i].Character.Parent = workspace.GameSystem.playersIngame
print("teleported?")
end
end)
6 Likes
KingBr1ck
(KingBr1ck)
August 11, 2023, 8:54pm
#2
You will have to disable the humanoids death state for this to work I think.
humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
5 Likes
Twivvn
(Twivvn)
August 11, 2023, 9:25pm
#3
For some reason the character just freezes when they get killed with the sword or reset with that?
4 Likes
KingBr1ck
(KingBr1ck)
August 11, 2023, 9:28pm
#4
You’ll have to manually use :LoadCharacter() on them if their death state is disabled.
So you would do:
→ LoadCharacter
→ Teleport
4 Likes
Twivvn
(Twivvn)
August 11, 2023, 9:32pm
#5
why would I load the character before I teleport it?
3 Likes
KingBr1ck
(KingBr1ck)
August 11, 2023, 9:35pm
#6
They won’t respawn otherwise since you disabled the death state. I’m not sure what your goal is though, do you only want this random spawn to happen with kill part and sword or anytime they die?
3 Likes
Twivvn
(Twivvn)
August 11, 2023, 9:39pm
#8
Actually it still doesn’t work. I want it all times they die. Ill send you the code.
3 Likes
Twivvn
(Twivvn)
August 11, 2023, 9:41pm
#9
Now they just don’t teleport and go to spawn when reset. Also why wont Humanoid.Died event work?
3 Likes
Twivvn
(Twivvn)
August 11, 2023, 9:51pm
#10
why does this not work either
3 Likes
KingBr1ck
(KingBr1ck)
August 11, 2023, 9:53pm
#11
You need to set their humanoid state type on the client as well I think so in a local script.
You probably dont need to use the loadcharacter then either since their character should stay intact.
Humanoid.Died does not fire because you set their state type to disabled on the server.
4 Likes
Twivvn
(Twivvn)
August 11, 2023, 9:54pm
#12
why do i need to set the death state to false though with .Died
2 Likes
KingBr1ck
(KingBr1ck)
August 11, 2023, 9:58pm
#13
You need to do this if you dont want the character to die, I assumed this from your original code where you tried setting their health back to 100.
Another way you could handle this if you don’t need that and just want people to always spawn randomly is to do this on Player.CharacterAdded event and just move the character on respawning.
Theres multiple ways you can do this but it depends on what you’re trying to achieve.
3 Likes
Twivvn
(Twivvn)
August 11, 2023, 10:00pm
#14
oh no, I do want the character to die and then respawn to the teleport.
with this code it does not work when they reset or get killed by a sword though
3 Likes
Twivvn
(Twivvn)
August 11, 2023, 10:01pm
#15
ill try the character added event too though
1 Like
KingBr1ck
(KingBr1ck)
August 11, 2023, 10:03pm
#16
You should just have something like this then
Player.CharacterAdded:Connect(function(character)
-- put their character in the folder you want
-- set the characters position
end)
3 Likes
Twivvn
(Twivvn)
August 11, 2023, 10:08pm
#17
now they just freeze on the kill part
2 Likes
KingBr1ck
(KingBr1ck)
August 11, 2023, 10:12pm
#18
You have removed the death state being disabled right?
2 Likes
Twivvn
(Twivvn)
August 11, 2023, 10:15pm
#19
yes, this is what i have. Now the player resets correctly with the kill part, but when they respawn they disappear and freeze
2 Likes
Twivvn
(Twivvn)
August 11, 2023, 10:21pm
#20
simplified to this how do i edit this cus now when the player resets they load to spawn
2 Likes
Twivvn
(Twivvn)
August 11, 2023, 10:25pm
#21
seems that the humanoid.Died event does not fire when i reset
2 Likes