#How to make sure the sword script only gives one kill value after one kill
1 messages · Page 1 of 1 (latest)
if there is any info that is you guys need to help me let me know
Probably because
If ( humanoid.Health <= 0 ) then
Also u are using findFirstChild but F should be caps
The event can fire multiple times per a swing you might want to track recently hit targets
Try using Humanoid.Died
Instead
did not work, do you know any way to track the targets?
I'm not really sure how I can do that
wait I don't understand what is your if block?
youre checking if health is lower than 0 and/or equal do you have any code that limits the health from dropping further?
** You are now Level 1! **
because the way I see it the health still drops
so it loops the kill
you should put the killvalue in another code that check if health drops below 1
I don't
** You are now Level 2! **
oh okay
Or edit the code to make it so once the health drops below 1 stop damage from being taken any further and give a kill
I see several empty or misaligned end statements that may cause logic errors
I dont see any end issues
maybe he doesn't know that he can insert end right after then instead of putting it below
no idea
Maybe he thinks if the if doesn't return true it exits the function?
U can make it return
you right maybe we should tell him
Yeah
He would still need to track the target or add a cooldown on the hitbox
If he keeps having value errors
Probably because the event is firing multipletimes
what you can do is check at the start of the function if health is lower than 0 if yes return end
The if statement on Top have return inside
do it works tho?
Is because I closed it
closed what?
if rightArm then?
"if rightarn then return end"
but what are you checking exactly with if rightArm?
The one I closed only had return
My bad for not showing everything
are you trying to make it so if it hit right arm it doesn't inflict damage?
** You are now Level 2! **
** You are now Level 9! **
The right arm check is just to be sure the right arm before finding it's child right grip
Right now I can't but the first five if statement just has return inside
Ok one second imma give it to my sister she knows how
Okay i know what the solution is
Actually before i tell u something more complicated lets test something first
On the line near the middle of the Blow function, where you return if the humanoid health is 0
You should try changing the comparator from == to <=
Bcs thats the condition ur checking to trigger an increase in kills
It needs a cooldown anyways between hits
Theres more to that why do you have like 3 if statement that checks if user is dead?
you only need 1
Test out what i said first and if it doesn’t work we can try something more complicated
Because of my situation I can't check if it will fix it
I was before on a computer but now I'm in car
well theres a more concrete solution but I wanted to see if that would fix it
Just ping me when u get to the computer 😩
At the start you check if CheckIfALive() then around the middle you check again if dead or health equals to 0 then at the end you check again if health is lower or equal to 0
its caused by the fact that multiple touches are occuring and so the event fires multiple times in an uncontrolled manner
I got that idea just I don't know another way to detect it without using touched function
it should check if the health is lower than or equal to 0 before inflicting damage in case the damage from a previous touch has lowered the health below 0, or else there may be a scenario where it may register an additional kill for touching an already-killed player. beacuse a negative is not equal to 0 so it wouldnt return.
u can use touched function
u just have to add a cooldowm
local cooling_down = false if cooling_down then return end cooling_down = true --run damage code task.wait(1)
cooling_down = false
also why do you check if rightarm exists? wouldnt the tool become unequipped automatically if the handle or the rightarm or the weld is destroyed?
Also why are you checking for if the sound is equal to nil?
To know if the sound doesn't exist
To first find the parent of rightgrip is there
Just to make sure of things
sound:Play(), is referencing the original (still nil) one — and it probably silently fails or errors does the sound work?
if sound == nil then
sound = Instance.new("Sound")
sound.Name = "GhostSound"
sound.SoundId = "rbxasset://sounds\HalloweenGhost.wav"
sound.Parent = script.Parent.Handle
end
The sound works
** You are now Level 3! **
Ok nvm then
its okay u dont need to check that
i also check everything though sometimes bcs it helps rule out potential causes of a bug to figure out the real cause lol
but u dont need to check for rightGrip, rightArm, or handle
The rightgrip is to not have the sword be a part of the damage
To just not count the sword or item as humanoid part
@vagrant hatch this is my code I tried using the first way it didn't fix it same thing for the second way, I also tried to create a object as to force the script not to repeat with the same character
have I done any mistake?
and is there any thing I can do else?
NVM I'M STUPID
I CHANGED THE WORNG SCRIPT
the first way to fix it worked
Nice