Players dying right after spawning?

So I got a few NPCs in my game which have projectiles. The last one that I fought with had .Touched, not sure if that’s the problem but it’d be nice if someone knows what the problem is.

I keep dying after spawning which is super weird. I did some debugging and it printed the health which instantly jumped from 25k to 100 for some weird reason. I looked on Developer Hub but couldn’t find a solution to this problem.

			func = part.Touched:Connect(function(hit)
				if hit.Parent:FindFirstChild('Humanoid') then
					local hum = hit.Parent.Humanoid
					if hum.Parent:FindFirstChild('Info') then return end
					if not cooldowns.Player[hum] or os.clock() - cooldowns.Player[hum]  > .05 then
						cooldowns.Player[hum] = os.clock()
						print(hum.Health)
						hum:TakeDamage(100)
					end
				end
			end)

If you could help me out, it’d be great!

3 Likes

Also, I checked all over the game, there are no viruses.

Looks like i think i found a problem. So basically if you touch a npc that are near you (which you will mostly likely die without even touching since they are so close to you) because according to the script. It takes your full health when you touch so it might be problem and try move npc or fix the script by replacing touched. If you dont know what to fix the script then you might need to search it up on roblox youtube tutorial. Hope it helped.

Npc is not close to me nor in range.

Also, this isn’t just a low level npc script, it’s just a hitbox I used for one of the projectiles. it’s just a guess that .Touched causes this.

Seems due to the fact you don’t seem to have any debounce, or was this supposed to be one:

?
Also, you might just be the first one that’ve seen, which has given many details about the issues. I now will thank you for that.

That’s a debounce/cooldown, yes.

Can you put a test script to make the player have a really high health? (Around 10 million.)

Done that. Still the same thing, the health jumps to 100.

It’s not the cooldown, I made sure the cooldown worked by debugging.

Could you show the scripts which change the health of the player? If there’s too much, mind showing the ones who would bring most attention?

There is only one, I just set the health with a scripting in starter character scripts (server script)

I might just remove touched and use raycasting instead.

2 Likes

still not working bruih :frowning: plz help sum1

1 Like

Did you use raycasting like you said above?