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
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)