#Ai script

36 messages · Page 1 of 1 (latest)

uncut flint
#

local barrier = workspace:FindFirstChild("Barrier") -- Replace "Barrier" with the actual name of your part

if barrier then
barrier.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
if humanoid and humanoid:IsA("NPC") then
humanoid:MoveTo(barrier.Position)
end
end)
else
print("Barrier part not found!")
end

#

I have this script that the roblox ai wrote, i want to know if I need to remove the ''-- Replace "Barrier" with the actual name of your part''?

idle mesa
#

any text after -- is a comment there's no need to remove it unless it visually doesn't please you

uncut flint
#

Ok thanks

#

Really helped

uncut flint
#

I placed and obby spawner, but I spawn in the middle of the place not on the spawner do u know what that is?

idle mesa
#

spawner.Position instead of barrier.Position if they're two different things

uncut flint
#

I will fake that helped lol

ornate ledgeBOT
#

studio** You are now Level 3! **studio

uncut flint
#

I already put the script on the part

#

Now if I start game the script will already be working?

idle mesa
#

barrier and part aren't referenced

#

won't work unless you reference something to those variables

uncut flint
#

How do I refer them?

idle mesa
#

local barrier = pathToPart

#

e.g. game.Workspace.Barrier

#

instead of pathToPart

uncut flint
#

Where do I put that?

#

Last thing i promisse

idle mesa
#

anywhere before the actual .Touched event

#

at the very start

uncut flint
#

Ok wait

#

Im doing it

idle mesa
uncut flint
#

Ok I will

idle mesa
#

they explain most of the basic features very simply

uncut flint
#

watch

#

Like that?

#

I will check the turotial rn ty

idle mesa
#

no, when you reference a variable to something you're trying to tell the computer it's location

#

within roblox the very big space which contains everything is called game

#

and the section which you see every part, every character and everything visual which isn't a GUI is Workspace

#

local barrier = game.Workspace.Barrier

uncut flint
#

Ok pls dont waste ur time typing this that I wont figure out, u just helped me thinking i gotta watch many tutorials

#

tysm