For context this is the script I'm using It's for a boss and I've been wanting to try something like this
local Torso = script.Parent.Torso
local hum = script.Parent.Human
local timer = 0
hum.Health = 2000
local function findTarget()
local agroDistance = 999999
local target = nil
for i, v in pairs(game.Workspace:GetChildren()) do
local human = v:FindFirstChild("Humanoid")
local torso = v:FindFirstChild("Torso")
if human and torso and v ~= script.Parent then
if (Torso.Position - torso.Position).magnitude < agroDistance then
agroDistance = (Torso.Position - torso.Position).magnitude
target = torso
end
end
end
return target
end
local function runTo()
local torso = findTarget()
if torso ~= nil then
hum:MoveTo(torso.Position)
end
end
local function rocket()
local target = findTarget()
local missile = Instance.new("Part", game.Workspace)
missile.Size = Vector3.new(1, 3, 1)
missile.Name = "Missile"
missile.Anchored = false
missile.Position = Torso.Position
missile.CFrame = CFrame.new(missile.Position, target.Position)
missile.BrickColor = BrickColor.Gray()
local homing = Instance.new("RocketPropulsion",missile)
homing.Target = target
homing.CartoonFactor = 0
homing:Fire()
missile.Touched:Connect(function(hit)
if hit and hit.Parent and hit.Parent ~= script.Parent then
local explode = Instance.new("Explosion", workspace)
explode.Position = missile.Position
missile:Destroy()
end
end)
end
local function spawnMinion()
local torsoPos = Torso.Position
local minion = game.Lighting.Minion:Clone()
minion.Parent = workspace
end
while true do
for i = 1, 3, 1 do
local forceField = Instance.new("ForceField", script.Parent)
forceField.Visible = false
wait(4)
rocket()
wait(1)
forceField:Destroy()
end
for i = 1, 140, 1 do
wait(0.1)
print(timer)
runTo()
timer = timer + 0.1
if timer == 7 then
timer = 0
spawnMinion()
end
end
end
Where it doesn't work is
if timer == 7 then
timer = 0
spawnMinion()
end
I have it print the Value of the Timer and it goes up but it doesn't activate the function, I don't know if its me being stupid or something extra I gotta do, any help?
