I created a punching script but it seems like nothing is HAPPENING!???

this under here is a local script in starter gui

local uis = game:GetService("UserInputService")
local reps = game:GetService("ReplicatedStorage")

local punching = false
local damaginging = true

local damage = 7
local cooldown = 2

local Event = reps:WaitForChild("Punch")

local plr = game.Players.LocalPlayer
local char = workspace:WaitForChild(plr.Name)
local hum = char:FindFirstChild("Humanoid")
local ra = char:WaitForChild("RightArm")

local punch = Instance.new("Animation")
punch.AnimationId = "rbxassetid://2210166769"
local punchtrack = hum:LoadAnimation(punch)

uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E and not punching then
	punching = true
	punchtrack:Play()
	punchtrack.KeyframeReached:Connect(function(Keyframe)
		if Keyframe == "End" then
			punching = false
			damaginging = true 
		end
	end)
end	
	end)
ra.Touched:Connect(function(part)
	if punching and part.Parent:FindFirstChild("Humanoid") and damaginging == true then
		damaginging = false
		local humdmg = part.Parent:FindFirstChild("Humanoid")
		Event:FireServer(humdmg, damage) 
	end
end)

and this here is a script in server script storage

local RS = game:GetService("ReplicatedStorage")
local punchevent = RS:WaitForChild("Punch")

punchevent.OnServerEvent:Connect(function(plrThatSent, humdmg, damage)
	humdmg:TakeDamage(damage)
end)

Help me...

4 comments

0

You shouldn't check for the character in Workspace, check for the character with the Character property of the Player object.

0

so line 14 is wrong? how can i check it with the player object?

0

local hum = game.Players.LocalPlayer.Character

0

ok