I am making a combat tool type thing and when I fire the event to damage the hit humanoid, it doesn't damage. Idk whats wrong because when I only had one server script it damaged the humanoid with the hitHumanoid:TakeDamage(10) thing.
This is the local script:
local animTable = {script:WaitForChild('Animation1'), script:WaitForChild('Animation2'), script:WaitForChild('Animation3'), script:WaitForChild('Animation4')}
local animPlace = 1
local db = false
local tool = script.Parent
local event = game.ReplicatedStorage:WaitForChild('Combat')
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local idle = character:WaitForChild('Humanoid'):LoadAnimation(script:WaitForChild('Idle'))
tool.Equipped:Connect(function()
idle:Play()
end)
tool.Unequipped:Connect(function()
idle:Stop()
end)
tool.Activated:Connect(function()
if not db then
db = true
print(animTable[animPlace].Name)
local attackAnim = character.Humanoid:LoadAnimation(animTable[animPlace])
attackAnim:Play()
print('1')
event:FireServer(animPlace, character)
animPlace = animPlace + 1
if animPlace == 5 then
animPlace = 1
end
attackAnim.Stopped:Wait()
wait(0.5)
db = false
end
end)
and this is the server script:
local event = game.ReplicatedStorage:WaitForChild('Combat')
local canAttack = true
local function first(hit)
canAttack = false
local hitHumanoid = hit.Parent:FindFirstChild('Humanoid')
if hitHumanoid then
print('Found Humanoid')
hitHumanoid:TakeDamage(10)
end
end
local function second(hit)
canAttack = false
local hitHumanoid = hit.Parent:FindFirstChild('Humanoid')
if hitHumanoid then
print('Found Humanoid')
hitHumanoid:TakeDamage(20)
end
end
local function damage(player, character, animPlace)
if animPlace == 1 then
if canAttack then
character:WaitForChild('Left Arm').Touched:Connect(function(hit)
first(hit)
end)
end
elseif animPlace == 2 then
if canAttack then
character['Right Arm'].Touched:Connect(function(hit)
first(hit)
end)
elseif animPlace == 3 then
if canAttack then
character['Left Leg'].Touched:Connect(function(hit)
canAttack = false
first(hit)
end)
elseif animPlace == 4 then
if canAttack then
character['Right Leg'].Touched:Connect(function(hit)
second(hit)
end)
end
wait(0.5)
canAttack = true
end
end
end
end
event.OnServerEvent:Connect(damage)

1 comment
Revali's Gale is now ready.