I want to know how to make a knife. No not the models, but a working script, that has damage randomized between 15-20 damage, and the knife to have durability. Specifically, have the knife be removed from your inventory after killing 10 people. And, I want to know how to sync my animations. My animation name is "attack", and the animation ID is 6398856018. I have 2 scripts, "Attack", and "Damage". I also have a BoolValue called "canDamage". And my scripts are (in order from the Attack script and Damage script)
local gear = script.Parent local attackAnim = script.attack
local cooldown = false
gear.Activated:Connect(function()
local humanoid = gear.Parent.FindFirstChildWhichIsA('Humanoid')
if cooldown == false then
cooldown = true
local loadedAnim = humanoid:LoadAnimation (attackAnim)
loadedAnim:Play ()
local canDamage = script.Parent.canDamage
canDamage.Value = true
wait (0.16)
loadedAnim:Stop ()
canDamage.Value = false
cooldown = false
end
end)
2nd script (Damage)
local gear = script.Parent local hitbox = script.Parent.Hitbox
local canDamage = script.Parent.canDamage
hitbox.Touched:Connect(function(hit)
if canDamage.Value == true then
hum:TakeDamage (15)
canDamage.Value = false
end
end)
I also have a part on the knife part called "hitbox", and it is the hitbox.
someone please tell me what I did wrong, and tell me how I can randomize the damage between 15-20!
