hello. this script makes my entity tween trough the rooms. the problem is that it wont disappear after and there is no error in the output.
local Rush_DB = true
function Rush()
if Rush_DB then Rush_DB = false
if script.ENTITY_FOLDER.ACTIVE_RUSH.Value ~= nil then
script.ENTITY_FOLDER.ACTIVE_RUSH.Value:Destroy()
end
script.EVENTS.LIGHTS_CONTROLLER:Fire("FLICKER")
script.EVENTS.HIDING_HIGHLIGHT:Fire()
task.wait(4)
local Cloned_Rush = script.ENTITY_FOLDER.RUSH.Value:Clone()
script.ENTITY_FOLDER.ACTIVE_RUSH.Value = Cloned_Rush
Cloned_Rush.Parent = game.Workspace
--game.Debris:AddItem(Cloned_Rush,20)
Cloned_Rush.RUSH.CHASE:Play()
Cloned_Rush.RUSH.CHASE_INNER:Play()
local SPAWN_ROOM_NUMBER = script.ROOM_AMOUNT.Value -6
local SPAWNROOM = script.ACTIVE_ROOMS_FOLDER.Value:FindFirstChild(SPAWN_ROOM_NUMBER)
Cloned_Rush.CFrame = script.SPAWN_ROOM.Value:FindFirstChild("END").CFrame
task.wait(4)
local activeRoomsChildren = script.ACTIVE_ROOMS_FOLDER.Value:GetChildren()
--local alreadyMovedTo = {}
script.ACTIVE_ROOMS_FOLDER.Value.ChildAdded:Connect(function(child)
table.insert(activeRoomsChildren, child)
end) -- adds the future children to the existing table
for idx,b in pairs(activeRoomsChildren) do
--table.insert(alreadyMovedTo,b)
if b:FindFirstChild("CHASE_NODES") then
for c,d in ipairs(b.CHASE_NODES:GetChildren()) do
if Cloned_Rush.RUSH.DAMAGE.RUNNING.Value == true then
local anglePart = d
if anglePart then
game.TweenService:Create(Cloned_Rush,TweenInfo.new(script.ENEMY_SPEED.Value,Enum.EasingStyle.Linear),{CFrame = anglePart.CFrame * CFrame.new(0,0,0)}):Play()
task.wait(script.ENEMY_SPEED.Value)
end
end
--[[task.wait()
if #script.ACTIVE_ROOMS_FOLDER.Value:GetChildren() > #script.ACTIVE_ROOMS_FOLDER.Value:GetChildren() and idx >= #script.ACTIVE_ROOMS_FOLDER.Value:GetChildren() then
task.wait(script.ENEMY_SPEED.Value)
local done = 0
for c,d in pairs(script.ACTIVE_ROOMS_FOLDER.Value:GetChildren()) do
if not table.find(alreadyMovedTo,d) then
if b:FindFirstChild("CHASE_NODES") then
for e,f in ipairs(d.CHASE_NODES:GetChildren()) do
if Cloned_Rush.RUSH.DAMAGE.RUNNING.Value == true then
local anglePart = f
if anglePart then
game.TweenService:Create(Cloned_Rush,TweenInfo.new(script.ENEMY_SPEED.Value,Enum.EasingStyle.Linear),{CFrame = anglePart.CFrame * CFrame.new(0,0,0)}):Play()
task.wait(script.ENEMY_SPEED.Value)
end
end
end
end
end
end
end]]
end
end
end
if script.ENTITY_FOLDER.ACTIVE_RUSH.Value ~= nil then
if script.ENTITY_FOLDER.ACTIVE_RUSH.Value.RUSH.RUNNING.Value == true then
script.ENTITY_FOLDER.ACTIVE_RUSH.Value:Destroy()
end
end
Rush_DB = true
end
end