So I Made a new script for a melee combat. The problem is it only does a few animation and it doesn't even damage the target.
Here's the local script:
local RS = game:GetService("ReplicatedStorage")
local Remotes = RS:WaitForChild("Remotes")
local Combat = Remotes:WaitForChild("Combat")
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local debounce = false
Mouse.Button1Down:Connect(function()
if debounce == false then
debounce = true
Combat:FireServer()
elseif debounce == true then
return
end
wait(0.3)
debounce = false
end)
and Here's the server script:
local RS = game:GetService("ReplicatedStorage")
local Remotes = RS:WaitForChild("Remotes")
local Combat = Remotes:WaitForChild("Combat")
local P1 = script.Punch1
local P2 = script.Punch2
local P3 = script.Punch3
local P4 = script.Punch4
local CC = 0
if CC == 4 then
CC = 0
end
Combat.OnServerEvent:Connect(function(Player)
local MeleeXP = Player.Data.Stats.MeleeXP
local CP = true
CC = CC +1
local Char = Player.Character
local Hum = Char.Humanoid
local LA = Char:WaitForChild("Left Arm")
local RA = Char:WaitForChild("Right Arm")
local LL = Char:WaitForChild("Left Leg")
local RL = Char:WaitForChild("Right Leg")
if CC == 1 then
local Anim = Hum:LoadAnimation(P1)
Anim:Play()
LA.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") then
MeleeXP.Value = MeleeXP.Value +1
local Hum = Hit.Parent:FindFirstChild("Humanoid")
Hum.WalkSpeed = 3
Hum.JumpPower = 0
if Hum.Parent.Name ~= Player.Name and CP then
Hum:TakeDamage(MeleeXP.Value/10)
wait(1)
Hum.WalkSpeed = 16
Hum.JumpPower = 50
end
end
end)
wait(0.3)
CP = false
elseif CC == 2 then
local Anim = Hum:LoadAnimation(P2)
Anim:Play()
RA.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") then
MeleeXP.Value = MeleeXP.Value +1
local Hum = Hit.Parent:FindFirstChild("Humanoid")
Hum.WalkSpeed = 3
Hum.JumpPower = 0
if Hum.Parent.Name ~= Player.Name and CP then
Hum:TakeDamage(MeleeXP.Value/10)
wait(1)
Hum.WalkSpeed = 16
Hum.JumpPower = 50
end
end
end)
wait(0.3)
CP = false
elseif CC == 3 then
local Anim = Hum:LoadAnimation(P3)
Anim:Play()
LA.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") then
MeleeXP.Value = MeleeXP.Value +1
local Hum = Hit.Parent:FindFirstChild("Humanoid")
Hum.WalkSpeed = 3
Hum.JumpPower = 0
if Hum.Parent.Name ~= Player.Name and CP then
Hum:TakeDamage(MeleeXP.Value/10)
wait(1)
Hum.WalkSpeed = 16
Hum.JumpPower = 50
end
end
end)
wait(0.3)
CP = false
elseif CC == 4 then
local Anim = Hum:LoadAnimation(P4)
Anim:Play()
LL.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") then
MeleeXP.Value = MeleeXP.Value +1
local Hum = Hit.Parent:FindFirstChild("Humanoid")
Hum.WalkSpeed = 3
Hum.JumpPower = 0
if Hum.Parent.Name ~= Player.Name and CP then
Hum:TakeDamage(MeleeXP.Value/10)
wait(1)
Hum.WalkSpeed = 16
Hum.JumpPower = 50
end
end
end)
wait(1)
CP = false
end
end)

2 comments
Anything in the output?
no sir, nothing