Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Players = game:GetService("Players")
- local Player = Players.LocalPlayer
- local active = true
- local function getClosestPlayer()
- local closestDistance = math.huge
- local closestPlayer = nil
- for _, otherPlayer in ipairs(Players:GetPlayers()) do
- if otherPlayer ~= Player then
- local character = otherPlayer.Character
- if character and character:FindFirstChild("HumanoidRootPart") then
- local distance = (character.HumanoidRootPart.Position - Player.Character.HumanoidRootPart.Position).magnitude
- if distance < closestDistance then
- closestDistance = distance
- closestPlayer = otherPlayer
- end
- end
- end
- end
- return closestPlayer
- end
- local function bitePlayer(targetPlayer)
- local args = {
- [1] = "Bite",
- [2] = targetPlayer.Character.Humanoid,
- [3] = targetPlayer.Character.BiteHitbox
- }
- ReplicatedStorage:WaitForChild("ServerEvents"):WaitForChild("Bite"):FireServer(unpack(args))
- end
- local function startBiting()
- while wait(0.1) do
- if active then
- local targetPlayer = getClosestPlayer()
- if targetPlayer then
- bitePlayer(targetPlayer)
- end
- end
- end
- end
- local function toggleScript()
- active = not active
- end
- game:GetService("UserInputService").InputBegan:Connect(function(input)
- if input.KeyCode == Enum.KeyCode.P then
- toggleScript()
- end
- end)
- startBiting()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement