Ive attempted fixing this but it still doesnt work and now I am stumped.
So I want it to add points when ever a player dies, and it does. But the thing is, if you continue hitting the player after he has died it will continue to add points and I dont know why.
So if you kill the guy and then continue to whack his body [Never thought id say that] it will continue to give you points.
Heres the code.
local Player = script.Parent.Parent.Parent
local EnemyKilled = game.ReplicatedStorage:WaitForChild("EnemyKilled")
script.Parent.BladeHitBox.Touched:connect(function(hit)
local HitPlayer = game.Players:GetPlayerFromCharacter(hit.Parent or hit.Parent.Parent)
if script.Parent.CanDamage.Value == true then
script.Parent.CanDamage.Value = false
local RandomDamage = math.random(1,3)
if RandomDamage == 1 then
if HitPlayer.TeamColor ~= Player.TeamColor then
hit.Parent.Humanoid:TakeDamage(75)
end
elseif RandomDamage == 2 then
if HitPlayer.TeamColor ~= Player.TeamColor then
hit.Parent.Humanoid:TakeDamage(80)
end
elseif RandomDamage == 3 then
if HitPlayer.TeamColor ~= Player.TeamColor then
hit.Parent.Humanoid:TakeDamage(85)
end
end
if hit.Parent.Humanoid.Health < 0 or hit.Parent.Parent.Humanoid.Health < 0 and KillDebounce == false then
KillDebounce = true
game.ReplicatedStorage.DataFile[Player.Name].DarthVaderKills.Value = game.ReplicatedStorage.DataFile[Player.Name].DarthVaderKills.Value + 1
game.ReplicatedStorage.DataFile[Player.Name].TotalKills.Value = game.ReplicatedStorage.DataFile[Player.Name].TotalKills.Value + 1
game.ReplicatedStorage.DataFile[Player.Name].ExperiencePoints.Value = game.ReplicatedStorage.DataFile[Player.Name].ExperiencePoints.Value + 50
game.ReplicatedStorage.DataFile[Player.Name].CP.Value = game.ReplicatedStorage.DataFile[Player.Name].CP.Value + 100
EnemyKilled:FireClient(Player)
delay(.25, function()
KillDebounce = false
end)
end
end
end)
The stuff to pay attention to is at the bottom, the last if statement. The reason I have to hit.Parents things is because I have parts attached to the player and if they hit a part it still has to register the hit.
Thank you for your time, hopefully we can figure this out :)

2 comments
What do you mean make it go away?
I have thought of a simpler solution because ive already written like I think 8 scripts with my way of adding points and I dont wanna go back and change them all honestly. What if there was a way you could make body parts go away after the player dies like you know how when a player dies the fall over into a bunch of parts. What if they fell over and instantly got destroyed. Is that possible