Error with dying and losing health for no reason

So when your infected in my game your suppose to die when you touch this yellow door but you dont die. It does nothing at all, and when you get infected you dont gain all the health your suppose to and I don’t know how to fix this. I know that its from this line of code with no errors.

if Player.Team == game.Teams.Infected then
		if Team_Player == true then
			Character.Humanoid.Name = "InfectedHumanoid"
			local newAnim = Instance.new("Animation")
			newAnim.AnimationId = InfectAnim
			Character.InfectedHumanoid.WalkSpeed = 0
			Character.InfectedHumanoid.JumpPower = 0
			Character.InfectedHumanoid.MaxHealth = 55
			Character.InfectedHumanoid.Health = Character.InfectedHumanoid.MaxHealth
			script.Parent.Animate.idle.Animation1.AnimationId = "rbxassetid://8177163203"
			script.Parent.Animate.idle.Animation2.AnimationId = "rbxassetid://8177163203"
			script.Parent.Animate.run.RunAnim.AnimationId = "rbxassetid://8177414818"
			script.Parent.Animate.walk.WalkAnim.AnimationId = "rbxassetid://8177414818"
			Character.InfectedHumanoid.Animator:LoadAnimation(newAnim):Play()
			wait(8)
			Character.InfectedHumanoid.WalkSpeed = 10
			Character.InfectedHumanoid.JumpPower = 20
			Team_Player = false
			script.Parent.InfectHitScript.Disabled = false
			Player.PlayerGui.InfectedPunchGui.Enabled = true
			Player.Backpack:ClearAllChildren()
			if Character:FindFirstChild("Club") then
				Character.Club:Destroy()
			end
		end

are you sure this is the right piece of code? this just looks like code to make someone infected, not to kill an infected

1 Like

I edited your post to wrap your code properly so it renders like code. Please read the stickied post next time!

1 Like

I don’t see anything here related to touching.

It is cause the door is functional and the humanoid does weird stuff when you get infected

so basically the door checks if your team is infected which functions and then kills you but when you get infected by losing too much health it breaks

i think i said it wrong should I send videos?

Puddles that infect you:
local team = BrickColor.new(“Really red”);
local part = script.Parent

part.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
if hit.Parent:FindFirstChild(“Humanoid”) then
plr.TeamColor = team
end
end
end)

  • you die when you hit the door

when your too low you turn infected:
Humanoid.HealthChanged:Connect(function(Health)
if Health <= 20 and Health ~= 0 and Player.Team == game.Teams.Players then
Player.TeamColor = BrickColor.new(“Really red”)
Humanoid.MaxHealth = 55
Humanoid.Health = 55
end
end)

– you dont die when you hit the door

they both use the same code which is this

Player:GetPropertyChangedSignal(“Team”):Connect(function()
if Player.Team == game.Teams.Infected then
if Team_Player == true then
Character.Humanoid.Name = “InfectedHumanoid”
local newAnim = Instance.new(“Animation”)
newAnim.AnimationId = InfectAnim
Character.InfectedHumanoid.WalkSpeed = 0
Character.InfectedHumanoid.JumpPower = 0
script.Parent.Animate.idle.Animation1.AnimationId = “rbxassetid://8177163203”
script.Parent.Animate.idle.Animation2.AnimationId = “rbxassetid://8177163203”
script.Parent.Animate.run.RunAnim.AnimationId = “rbxassetid://8177414818”
script.Parent.Animate.walk.WalkAnim.AnimationId = “rbxassetid://8177414818”
Character.InfectedHumanoid.Animator:LoadAnimation(newAnim):Play()
wait(8)
Character.InfectedHumanoid.WalkSpeed = 10
Character.InfectedHumanoid.JumpPower = 20
Team_Player = false
script.Parent.InfectHitScript.Disabled = false
Player.PlayerGui.InfectedPunchGui.Enabled = true
Player.Backpack:ClearAllChildren()
if Character:FindFirstChild(“Club”) then
Character.Club:Destroy()
end
end

1 Like

I hope this is more clear of the situation im not the best at explaining

try to use specific number values for health and maxhealth (dont make health equal to maxhealth via path) and dont name the humanoid to something else (might break something)

1 Like

okay nevermind i was wrong wait 1 sec

did it work this time? I hope it did

Yes it has thank you very much! It was hard solving the issue cause no errors were popping up

1 Like