I was following a tutorial on how to make a throw able knife but when i throw it It does not do damage please help me.

local tool = script.Parent
local anim = tool:WaitForChild("KnifeThrowAnimation")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local knifeThrow = game.ReplicatedStorage.KnifeThrow

local cooldown = 2
local debounce = false


tool.Activated:Connect(function()
	if player.Character then
		local humanoid = player.Character:FindFirstChild("Humanoid")
		
		if humanoid then
			if debounce then return end
			debounce = true
			
			local charge = 1
			
			local loadedAnim = humanoid:LoadAnimation(anim)
			loadedAnim:Play()
			
			loadedAnim:GetMarkerReachedSignal("Charge"):Connect(function(chargeParam)
				charge = chargeParam
			end)	
			
			
			local connection = loadedAnim:GetMarkerReachedSignal("PauseAnimation"):Connect(function()
				loadedAnim:AdjustSpeed(0)
			end)
			
			
			tool.Deactivated:Wait()
			
			loadedAnim:AdjustSpeed(-10)
			connection:Disconnect()
			
			knifeThrow:FireServer(mouse.Hit, tool.Handle.Position, charge)
			
			wait(cooldown)
			debounce = false
		end
	end
end)

2 comments

0

maybe after you find the humanoid make it where to whenever a humanoid is found, it deals damage https://developer.roblox.com/en-us/api-reference/function/Humanoid/TakeDamage

0

@Ponytails2017 i dont understand