local hitbox = script.Parent.DMGpart
local player = game.Players.LocalPlayer
local userInputService = game:GetService("UserInputService")
local damageActive = false
local function onHit(hit)
local hum = hit.Parent:FindFirstChildWhichIsA("Humanoid")
if hum then
hum:TakeDamage(0.5)
end
end
local function onInputBegan(input, gameProcessedEvent)
if gameProcessedEvent then return end
if input.UserInputType == Enum.UserInputType.MouseButton2 then -- Проверка на ПКМ
if not damageActive then
damageActive = true
hitbox.Touched:Connect(onHit)
wait(3) -- Скрипт будет активен 3 секунды
hitbox.Touched:Disconnect(onHit) -- Отключить обработчик после 3 секунд
damageActive = false
end
end
end
userInputService.InputBegan:Connect(onInputBegan)
local hitbox = script.Parent.DMGpart
hitbox.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChildWhichIsA("Humanoid")
hum:TakeDamage(0.5)
end)