I want it to deal damage only to the part that is touched instead of all the parts
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local RunServ = game:GetService("RunService")
local ContextActionService = game:GetService("ContextActionService")
local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()
--if not Char.Parent then Char = Player.CharacterAdded:Wait() end
local Hum = Char:WaitForChild("Humanoid")
local HRP = Char:WaitForChild("HumanoidRootPart")
local Animator = Char:WaitForChild("Humanoid"):WaitForChild("Animator")
local Zone1Parts = game.Workspace.Map.Zone1.Model
local Mouse = Player:GetMouse()
local tool = script.Parent
local Storage = RS.Storage
local AnimationFolder = Storage.Animations
local PunchAnim1 = Hum:LoadAnimation(AnimationFolder.FloorPunch1)
local PunchAnim2 = Hum:LoadAnimation(AnimationFolder.FloorPunch2)
local Debounce = false
local lastAttackTime = 0
local comboStep = 0
local cd = .5
local function AttackParts()
for _, v in pairs (Zone1Parts:GetDescendants())do
print(v)
if v.Name == 'Part1' then
v.Humanoid:TakeDamage(10)
end
if v.Name == 'Part2' then
v.Humanoid:TakeDamage(10)
end
if v.Name == 'Part3' then
v.Humanoid:TakeDamage(10)
end
if v.Name == 'Part4' then
v.Humanoid:TakeDamage(10)
end
if v.Name == 'Part5' then
v.Humanoid:TakeDamage(10)
end
if v.Name == 'Part6' then
v.Humanoid:TakeDamage(10)
end
if v.Name == 'Part7' then
v.Humanoid:TakeDamage(10)
end
if v.Name == 'Part8' then
v.Humanoid:TakeDamage(10)
end
if v.Name == 'Part9' then
v.Humanoid:TakeDamage(10)
end
end
end
tool.Equipped:Connect(function(Mouse)
Mouse.Button1Down:Connect(function()
if Debounce == false then
Debounce = true
local currentTime = tick()
if currentTime - lastAttackTime <= 0.7 and comboStep == 1 then -- Check if it's a combo and on the second step
PunchAnim1:Play()
AttackParts()
comboStep = 0 -- Reset the combo
wait(cd)
Debounce = false
elseif currentTime - lastAttackTime <= 0.7 then -- Otherwise start the combo
PunchAnim2:Play()
AttackParts()
comboStep = 1 -- Set the combo to the second step
wait(cd)
Debounce = false
else -- Otherwise play the first punch
PunchAnim1:Play()
AttackParts()
comboStep = 0 -- Reset the combo
wait(cd)
Debounce = false
end
lastAttackTime = currentTime
end
end)
end)
tool.Unequipped:Connect(function()
print("Tool unequipped")
end)