I use this script to make it where it moves a bot to it's spawning location when it touches the part. No matter what I do, it still bypasses the brick, and it gets into the lobby and kills the players that aren't attacking it. I get no errors, I just get a bunch of print that says something like "Invisible Block: " and a bunch of numbers. I use 2 scripts that basically tie in together.
My script works amazing in studio, just how I want it to. Then, I go in-game, and the longer/bigger script doesn't do anything whatsoever. In studio, it still continues to work even after the bot is respawned. I don't know anything else to do, I tried everyone's suggestions.
Invisible block script:
local SpawnPos=Vector3.new(36.89, 3, -114)
local Bots=workspace.BotArea
script.Parent.Touched:connect(function(Hit)
if Hit:IsDescendantOf(Bots) then
for _,Bot in pairs(Bots:GetChildren()) do
if Hit:IsDescendantOf(Bot) then
Bot:MoveTo(SpawnPos)
end
end
end
end)
Sends bot back into it's spawning position script:
local Bot=script.Parent
function FindNearestTorso(Pos)
local BestTarget=nil
local BestDist=500
for i,v in pairs(game:GetService("Players"):GetPlayers()) do
if v.Character and v.Character:FindFirstChild("Torso") then
local Character=v.Character
local Torso=Character.Torso
local Dist=(Torso.Position-Pos).magnitude
local Ray=Ray.new(Pos,(Torso.Position-Pos).unit*Dist)
local Part,Pos=workspace:FindPartOnRayWithIgnoreList(Ray,{Bot,Character})
if not Part and Dist<BestDist then
BestTarget=Torso
BestDist=Dist
end
end
end
return BestTarget
end
while true do
wait()
local target = FindNearestTorso(Bot.Torso.Position)
local SpawnPos=Vector3.new(36.89, 3, -114)
if target ~= nil then
Bot.Humanoid:MoveTo(target.Position, target)
else
Bot.Humanoid:MoveTo(SpawnPos)
end
end

7 comments
It seems that "Invisible Block" is the closest block. Maybe the Touched function isn't firing when the bot touches it (touched isn't very reliable :/). Maybe you could check to see if the player it's going towards is inside a certain radius (the lobby)?
There is no Connection Line.
instead of commenting, please add a answer with a script.
Basically, when he first spawns the brick works. Then, I go in and kill him, and then go out. Then I go back in, and out to test the "else Bot.Humanoid:MoveTo(SpawnPos)" and he goes straight through the brick.
People generally comment to get clarification and pose ideas of answers. We generally discourage people from posting answers that they are not sure about. Please let people continue to comment!
You should remove line 5 in your first script, there is not really a point of it.
Alright, I am looking at the top code block, I don't see anything wrong with it. My suggestion is making multiple prints and see where the script is failing... I am sorry I can not be any more help...