-- Configuration local MIN_INTERVAL = 20 local MAX_INTERVAL = 40 local PERCENTAGE_INCREMENT = 5 local INCREMENT_INTERVAL = 0.5 local DECREMENT_INTERVAL = 0.3 local HOLD_DURATION_TO_DECREASE = 1 local INTERACT_KEY = Enum.KeyCode.E
local model = script.Parent local billboardGui = model:WaitForChild("BillboardGui") local textLabel = billboardGui:WaitForChild("TextLabel") local warningSound = model:WaitForChild("WarningSound") -- Assuming a Sound object named "WarningSound" is inside the model
billboardGui.Enabled = false warningSound.Looped = true
local function findNearestPlayerToModel(model) local nearestPlayer = nil local minDistanceSquared = math.huge local modelPosition = model:GetPivot().Position
for _, player in ipairs(Players:GetPlayers()) do local character = player.Character if character then local humanoidRootPart = character:FindFirstChild("HumanoidRootPart") if humanoidRootPart then local playerPosition = humanoidRootPart.Position local distanceSquared = (playerPosition - modelPosition):Dot(playerPosition - modelPosition)
if distanceSquared < minDistanceSquared then
minDistanceSquared = distanceSquared
nearestPlayer = player
end
end
end
if distanceSquared < minDistanceSquared then
minDistanceSquared = distanceSquared
nearestPlayer = player
end
end
end
end return nearestPlayer end
local function runPercentageSequence() local waitTime = math.random(MIN_INTERVAL, MAX_INTERVAL) wait(waitTime)
billboardGui.Enabled = true textLabel.Text = "0%" local percentage = 0 warningSound:Play()
local isInteracting = false local interactionStartTime = nil
local function inputBegan(input, gameProcessedEvent) if input.KeyCode == INTERACT_KEY and not gameProcessedEvent then local nearestPlayer = findNearestPlayerToModel(model) if nearestPlayer and nearestPlayer.Character then local character = nearestPlayer.Character local humanoidRootPart = character:FindFirstChild("HumanoidRootPart") if humanoidRootPart then local distanceSquared = (humanoidRootPart.Position - model:GetPivot().Position):Dot(humanoidRootPart.Position - model:GetPivot().Position) if distanceSquared < 100*100 then -- Interaction range, adjust as needed isInteracting = true interactionStartTime = tick() end end end end end
local function inputEnded(input, gameProcessedEvent) if input.KeyCode == INTERACT_KEY then isInteracting = false interactionStartTime = nil end end
UserInputService.InputBegan:Connect(inputBegan) UserInputService.InputEnded:Connect(inputEnded)
while percentage < 100 and billboardGui.Enabled do if isInteracting and tick() - interactionStartTime >= HOLD_DURATION_TO_DECREASE then percentage = percentage - 1 if percentage < 0 then percentage = 0 end textLabel.Text = percentage .. "%" wait(DECREMENT_INTERVAL) if percentage <= 0 then billboardGui.Enabled = false warningSound:Stop() UserInputService.InputBegan:Disconnect(inputBegan) UserInputService.InputEnded:Disconnect(inputEnded) return -- Exit sequence if percentage reduced to 0 end else wait(INCREMENT_INTERVAL) percentage = percentage + PERCENTAGE_INCREMENT textLabel.Text = percentage .. "%" end end
if percentage >= 100 and billboardGui.Enabled then local nearestPlayer = findNearestPlayerToModel(model) if nearestPlayer then local character = nearestPlayer.Character if character then local humanoid = character:FindFirstChild("Humanoid") if humanoid then humanoid.Health = 0 print("Player " .. nearestPlayer.Name .. " killed!") end end end billboardGui.Enabled = false warningSound:Stop() end
UserInputService.InputBegan:Disconnect(inputBegan) UserInputService.InputEnded:Disconnect(inputEnded) end
while true do pcall(runPercentageSequence) end *