Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local localPlayer = Players.LocalPlayer
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local function getNearestPlayer(character)
- local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
- if not humanoidRootPart then return end
- local nearestPlayer = nil
- local shortestDistance = math.huge
- for _, player in ipairs(Players:GetPlayers()) do
- if player ~= localPlayer and player.Character then
- local targetRoot = player.Character:FindFirstChild("HumanoidRootPart")
- if targetRoot then
- local distance = (humanoidRootPart.Position - targetRoot.Position).Magnitude
- if distance < shortestDistance then
- shortestDistance = distance
- nearestPlayer = player
- end
- end
- end
- end
- return nearestPlayer
- end
- while true do
- local character = localPlayer.Character or localPlayer.CharacterAdded:Wait()
- local nearestPlayer = getNearestPlayer(character)
- if nearestPlayer then
- local args = {
- "player",
- {
- meleeType = "meleemegapunch",
- hitPlayerId = nearestPlayer.UserId
- }
- }
- ReplicatedStorage:WaitForChild("devv"):WaitForChild("remoteStorage"):WaitForChild("wth"):FireServer(unpack(args))
- else
- warn("No nearby players found!")
- end
- wait(0.2) -- Задержка между выполнениями для оптимизации
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement