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
I optimized it but pretty much used your system, so I assume I don't have to go into much detail explaining it all. I also added a little bit to it to make it a little more fun :D
local bot, agility, bestTarget, target, bestWait do agility = 0.25 bot = script.Parent; bestTarget = function (position) local Victim = nil local Distance = 100 for key, player in pairs(game.Players:GetPlayers()) do if pcall(function() return player.Character.Torso end) then local character = player.Character local torso = character.Torso local magnitude = (torso.Position - position).magnitude local ray = Ray.new(position,(torso.Position - position).unit * magnitude) local hit, position = workspace:FindPartOnRayWithIgnoreList(ray,{bot, character}) if not hit and magnitude <= Distance then Victim = torso Distance = magnitude end end end return Victim end bestWait = function() return (not target and agility or 0.5) end end while wait(bestWait()) do local iSpawn = Vector3.new(36.89, 3, -114) local target = bestTarget(bot.Torso.Position) if target ~= nil then bot.Humanoid:MoveTo(target.Position) target.Parent.Humanoid.Died:connect(function() target = nil end) else bot.Humanoid:MoveTo(iSpawn) end end
You code looks right. Although not a real solution, I can simplify the touch script.
local SpawnPos=Vector3.new(36.89, 3, -114) script.Parent.Touched:connect(function(hit) if hit.Parent and hit.Parent.Name == "Bot" then hit.Parent:MoveTo(SpawnPos) end end)
Might as well try it. As I said, your code looks good.
Instead of using a great big script, you should... 1. Go into Roblox Studio 2. Click on the brick 3. If the Properties pane is not open already, please open it. 4. Find Transparency, set that to 1. Done!
If you want to make sure no one knows of it's existence, uncheck CanCollide.