How do I make an NPC that cannot go to certain areas e.x spawn point. Thanks you very much!
Note: I have very little scripting skills, and I have searched for tutorials to help me but I don’t understand Sorry for inconvenience
How do I make an NPC that cannot go to certain areas e.x spawn point. Thanks you very much!
Note: I have very little scripting skills, and I have searched for tutorials to help me but I don’t understand Sorry for inconvenience
if NPC.HumanoidRootPart.CFrame == Vector3.new(x,y,z) then
NPC.Humanoid.MoveToPoint = Vector3.new(x,y,z)
end
you’re supposed to use pathfinding modifers BUT they’re in beta. So they don’t work outside of studio :(. So i’d recommend making a custom path. Use this game as a refrence. Feel free to use the scripts and stuff.
Custom path test.rbxl (64.9 KB)
Does this work with large areas?
Region3 | Roblox Creator Documentation can be used for that or you could check if they are touching an invisible part
Is there a script to make it so if it is touching a part it will go the other way or something? (Maybe it can teleport back somewhere)
I am on iPad, i’ll test that out when I can
if table.find(NPC.RightFoot:GetTouchingParts(),"DontTouch") then
NPC.Humanoid:MoveTo(Alabama)
end
He said he doesn’t have much scripting knowledge. He probably doesn’t understand what half the things do in this script.
He could search it up on the api
Put part name here? Should I do
PartName.workspace
here?
Yes put the parts actual name there
Do I need to reference it? Or just part name is alright?
Part name is alright but you have to put quotes around it
local part = workspace:FindFirstChild("Part") --change to name of part
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("HumanoidRootPart") then
local hmr = hit.Parent.HumanoidRootPart
hmr.CFrame = CFrame.new(0, 0, 0)
end
end)
Simple script which teleports you back to 0, 0, 0 when you touch a part. It’s a server script, please it in ServerScriptService, and make sure the name of the part is valid.