Knife-Script(s) not working

  1. What do you want to achieve? I’m making a script that does damage to players if they touch the blade of my knife

  2. What is the issue? Won’t work for some reason, no errors, I believe it has something to do with my debounce but I don’t know what?

  3. What solutions have you tried so far? Every solution basically lol

Main Local Script:


local Knife = script.Parent.Parent
local Blade = Knife.Blade
local Handle = Knife.Handle
local SlashAnim = Knife.Animations.Slash

local EquipSound = Handle.Equip
local HitSound = Handle.Hit
local SlashSound = Handle.Slash
local UnEquipSound = Handle.UnEquip

local CanDamage = script.Parent.Parent.Values.CanDamage.Value

local Cooldown = Knife.Values.Cooldown.Value
local CooldownWait = 1

Knife.Equipped:Connect(function()
	EquipSound:Play()
end)

Knife.Unequipped:Connect(function()
	UnEquipSound:Play()
end)

Knife.Activated:Connect(function()
	local Humanoid = Knife.Parent:FindFirstChildWhichIsA('Humanoid')
	if Humanoid and Cooldown == false then
		Cooldown = true
		CanDamage = true
		local PlaySlashAnim = Humanoid:LoadAnimation(SlashAnim)
		PlaySlashAnim:Play()
		wait(0.3)
		SlashSound:Play()
		wait(CooldownWait)
		Cooldown = false
		CanDamage = false
	end
end)

Server-Kill Script

local CanDamage = script.Parent.Parent.Values.CanDamage.Value
local Damage = script.Parent.Parent.Values.Damage.Value
local Blade = script.Parent.Parent.Blade

Blade.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and CanDamage == true then
		hit.Parent:TakeDamage(Damage)
		CanDamage = false
	end
end)

Both scripts are in a folder named (Scripts)

Maybe you have virus in your game that’s breaks everything, it happens to me once

That doesnt help at all, this is a new baseplate, everything was made and modeled by me…

Add some ‘printing’ statements to your code, and share the results, I’m not sure where the code is breaking!

I think it’s because you didn’t set “CanDamage” to false in the server script.