How do I make a punch script that does damage and makes stats go up for a R15 rig

So I am making a punching script so when you punch someone it deals damage of the amount of power a player has but the damage function don’t work

So can someone figure out how to fix it here’s a video of what I got so far

and I do got events
image

and here are the scripts that I have

--Punch Player or Humanoid script
script.Parent.Events.PunchPlayer.OnServerEvent:Connect(function(plr)
	local mouse = script.Parent.MouseScript
	mouse.Disabled = false
	wait(1)
mouse.Disabled = true	
end)
--Stat gain Script
local debounce = true

local StatAdd = script.Parent.Settings.StatAdding.Value
local multi = script.Parent.Settings.Multiplier.Value
local cooldown = script.Parent.Settings.Cooldown.Value
script.Parent.Events.Punch.OnServerEvent:Connect(function()
	if debounce then
		debounce = false
		
		local Strength = game.Players[script.Parent.Parent.Name].StatsData.Power
Strength.Value = Strength.Value + StatAdd * multi
		wait(cooldown)
		debounce = true
	end
end)
--Tool Animation and Event Fire Script
local weight = script.Parent
local Humanoid = game.Workspace:WaitForChild(game.Players.LocalPlayer.Name):WaitForChild('Humanoid')
local LPunch = Humanoid:LoadAnimation(script.Parent.Animations.LeftPunch)
local RPunch = Humanoid:LoadAnimation(script.Parent.Animations.RightPunch)


local debounce = true
local cooldown = script.Parent.Settings.Cooldown.Value
local ScriptCooldown = script.Parent.Settings.ScriptDisableCooldown.Value

weight.Activated:Connect(function()
	if weight.Parent == game.Players.LocalPlayer.Character and debounce then
		debounce = false
		script.Parent.Events.Punch:FireServer()
		local random = math.random(1,2)
		if random == 1 then
			LPunch:Play()
		else
			if random == 2 then
				RPunch:Play()
		end
			end
		
		wait(cooldown)
		debounce = true
	end
end)

-- Damage To player local script
local Tool = script.Parent
local Player = game.Players.LocalPlayer
local Char = Player.Character
local Cooldown = script.Parent.Settings.Cooldown.Value
local Mouse = Player:GetMouse()

Tool.Activated:Connect(function()
	local debounce = true
	Tool.Events.PunchPlayer:FireServer()
	
	if Tool.Parent == Player.Character and debounce then
		debounce = false
		local handle = script.Parent.Handle
		handle.Touched:Connect(function(hit)
			local damage = 1
			if hit.Parent == Player.Character then return end
			if hit and hit.Parent:FindFirstChild("Humanoid") then 
				local debounce = true

				local EnemyHum = hit.Parent:FindFirstChild("Humanoid")
				EnemyHum:TakeDamage(damage*Player.StatsData.Power.Value+0)
		wait(Cooldown)
		debounce = true
		Tool.Events.PunchPlayer:FireServer(Mouse.Hit)
	end
	end)
	end
		end)

By just reading the output. Is that error related with your script?..

You are sending too much data quickly to DataStore. Its placing it on queue.
Read that yellow output.

So there is no errors with the scripts but its just not doing the damage taken from the part

Since I see that yellow error, yes, the script has an error approach. I dont know what you are storing on DataStore everytime the dummy gets a punch… Going from there, yes, the script has errors.

Its hard to read all your script and find the exact error, first you should get rid of that yellow warning, you dont know if thats the main problem

Well i mean its gain points not for punching the dummy

The only way I could help you, is to reproduce ur entire system. Which I cannot do for now (kinda busy)
I would copy those scripts and find whats the error. I will start with removing all the systems that are not required for the test, like “gaining points” (Which should not be saved on each punch, DataStore cant be called in that way). Just try to make the tool to damage the humanoid first, without anything else. When you got it, just implement it into your original system. I would like to help you more, but its a task that would take me long time. Sorry u ,u

1 Like