Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Reminder: Join a Team and select Class and Always Equip Gun To make Script Work(Actually you don't need to Equip Gun the Script alway Work anyway but if Script doesn't work just equip)
- while true do
- local player = game.Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local localroot = character:WaitForChild("HumanoidRootPart")
- local function closestEnemy()
- local range = math.huge
- local target = nil
- for _, v in pairs(game.Players:GetPlayers()) do
- if v ~= player and v.Team ~= player.Team and v.Character then
- local enemyRoot = v.Character:FindFirstChild("HumanoidRootPart")
- if enemyRoot then
- local distance = (localroot.Position - enemyRoot.Position).magnitude
- if distance < range then
- range = distance
- target = v
- end
- end
- end
- end
- return target
- end
- local enemy = closestEnemy()
- if enemy then
- local enemyCharacter = enemy.Character
- local enemyRoot = enemyCharacter:FindFirstChild("Head")
- local enemyHumanoid = enemyCharacter:FindFirstChild("Humanoid")
- if enemyRoot and enemyHumanoid then
- spawn(function()
- while enemyHumanoid.Health > 0 do
- local args = {
- [1] = enemyHumanoid,
- [2] = math.huge,
- [3] = enemyRoot
- }
- game:GetService("ReplicatedStorage").RemoteEvents.DamageEvent:FireServer(unpack(args))
- wait(0.1)
- end
- end)
- end
- end
- wait(0.1)
- end
Advertisement
Comments
-
- Equip the Gun to Make Script work And here link game
- https://www.roblox.com/games/2292818376/Realistic-Tank-Simulator-2-0-BETA
Add Comment
Please, Sign In to add comment