local Players = game:GetService("Players").LocalPlayer
local Workspace = game:GetService("Workspace")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Character = Players.Character or Players.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local StartAttackEvent = ReplicatedStorage:WaitForChild("RemoteObject"):WaitForChild("RequestAttack")
local SetAttackEvent = ReplicatedStorage:WaitForChild("RemoteObject"):WaitForChild("SetAttacking")
local SetDataTarget = ReplicatedStorage:WaitForChild("RemoteObject"):WaitForChild("SetDataTarget")
local Range = 30
Players.CharacterAdded:Connect(function(newchar)
Character = newchar
HumanoidRootPart = newchar:WaitForChild("HumanoidRootPart")
end)
RunService.Heartbeat:Connect(function(...)
local Targets = {}
for _, obj in Workspace.Camera:GetChildren() do
local MobRoot = obj:FindFirstChild("HumanoidRootPart")
local Humanoid = obj:FindFirstChild("Humanoid")
if obj:IsA("Model") and Humanoid and Humanoid.Health > 0 and MobRoot then
if (HumanoidRootPart.Position - MobRoot.Position).Magnitude <= Range then
table.insert(Targets, obj)
end
end
end
if #Targets > 0 then
SetAttackEvent:FireServer(true)
for _, mob in Targets do
SetDataTarget:FireServer(mob.Data.Value)
StartAttackEvent:FireServer({{mob.Data.Value, 0}})
end
end
end)
Comments
No comments yet
Be the first to share your thoughts!