A script I’ve been tweaking for awhile has a glaring issue, and I’m unsure on how I can fix it.
Even more strange is that this code works in another script I have, though it’s formatted differently.
Basically what’s going on is my RayCast script seems to not award the player a kill when it deals damage to well… kill an enemy player.
Instead, it does the amount needed to kill the player.
For example, someone is left at 10 HP.
My weapon here does 20.
Instead of dealing the 20 damage and giving me a kill, it’ll do the exact 10 damage needed to kill an enemy and it doesnt award anything.
Any ideas on how to fix this? I can show more code if needed, though I figured this block is most relevant.
Thanks in advance!
local Result = workspace:Raycast(Handle.Position, RayDirection, NewRay)
if Result then -- if we got result back
if Result.Instance then
-- Something was hit
if not Result.Instance.Parent:FindFirstChild("Humanoid") then -- return if result is not a player
return
end
if Player.Team == game.Players:GetPlayerFromCharacter(Result.Instance.Parent).Team then
return
end
if Result.Instance.Parent:FindFirstChild("Humanoid") then
Result.Instance.Parent.Humanoid.Health -= DAMAGE
if Result.Instance.Parent.Humanoid.Health - DAMAGE <= 0 then
Player.leaderstats.KO.Value += 1
end
end
end
end
end)