1local Player = game:GetService("Players").LocalPlayer
2local Workspace = game:GetService("Workspace")
3local ReplicatedStorage = game:GetService("ReplicatedStorage")
4local RunService = game:GetService("RunService")
5local Character = Player.Character or Player.CharacterAdded:Wait()
6local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
7local StartAttackEvent = ReplicatedStorage:WaitForChild("RemoteObject"):WaitForChild("RequestAttack")
8local SetAttackEvent = ReplicatedStorage:WaitForChild("RemoteObject"):WaitForChild("SetAttacking")
9local SetDataTarget = ReplicatedStorage:WaitForChild("RemoteObject"):WaitForChild("SetDataTarget")
10local Range = 30
11
12RunService.RenderStepped:Connect(function(...)
13 for _, obj in pairs(Workspace.Camera:GetChildren()) do
14 if obj:IsA("Model") and obj.Humanoid.Health > 0 then
15 local MobRoot = obj:FindFirstChild("HumanoidRootPart")
16 if MobRoot then
17 if (HumanoidRootPart.Position - MobRoot.Position).Magnitude <= Range then
18 SetDataTarget:FireServer(obj.Data.Value)
19 SetAttackEvent:FireServer(true)
20 StartAttackEvent:FireServer({{obj.Data.Value, 0}})
21 end
22 end
23 end
24 end
25end)
Comments
…