I want to make a punch script that hurts the humanoid or player that touches the player doing the punch animation. I already have the script but it dosent make other humanoids take damage what do i do?


local user = game:GetService("UserInputService")
local play = game:GetService("Players")
local player = game.Players.LocalPlayer
local character = player.Character
local human = script.Parent
local target = human:FindFirstChild("Humanoid")
local hmd = character:WaitForChild("Humanoid") 
local debounce = false
local anim = Instance.new("Animation")
local pain = true
local enemy = game:FindFirstChild("Model")
anim.AnimationId = "rbxassetid://2642258675"
local key = Enum.KeyCode.Q
local function IsQkeydown()
	return user:IsKeyDown(key)
	end


local function Input(input, gameProcessedEvent)
	if not IsQkeydown() then
	else
	
		print("hit")
		local AnimationTrack = hmd:LoadAnimation (anim)
		AnimationTrack:Play()
		if enemy.Touched:Connect(function(hit)
			if debounce == false then
				debounce = true
				if hit.Parent:IsA("Model") then
					if hit.Parent:FindFirstChildOfClass("Humanoid")
					then
					target = hit.Parent:FindFirstChildOfClass("Humanoid")
				end
			end
	enemy:TakeDamage(5)
	wait (0.4)
		 debounce = false
		end
		
	 end)

			
			
	then	end 
		
			end
		end
		
 
user.InputBegan:Connect(Input)


2 comments

0

You need RemoteEvents

0

This website isnt for fixing other peoples scripts. Its in the site guidelines.