Hi. i want to make tower defense type game and the issue is troop keep doing that
robloxapp-20230906-2314220.wmv (1013.2 KB)
the problem i cant get multiple rig (i dont know is there any way to get multiple models)
troop keep attacking like one by one and i want troops attack first one
here what i did used for that
local Model = script.Parent.Parent
local gun = Model.Handgun
local RunService = game:GetService("RunService")
local ss = game:GetService("ServerStorage")
local troops = require(ss.Troops)
while RunService.Heartbeat:Wait() do
for _, NearestPlayer in pairs(game.Workspace:GetChildren()) do
if NearestPlayer.Name == "Normal" then
local distance = (Model.PrimaryPart.Position - NearestPlayer.PrimaryPart.Position).magnitude
if NearestPlayer == nil then continue end
if distance <= troops.pistol.level1.distance then
Model.PrimaryPart.CFrame = CFrame.lookAt(Model.PrimaryPart.Position,Vector3.new(NearestPlayer.PrimaryPart.Position.X,Model.PrimaryPart.Position.Y,NearestPlayer.PrimaryPart.Position.Z))
gun.shooting:Fire()
NearestPlayer.Health.Value = NearestPlayer.Health.Value - troops.pistol.level1.damage
wait(.5)
end
end
end
end