In My Game That I'm Working On I Have A Teleporter To A Pirate Ship That Has A Bunch Of Wandering NPC's.My Problem Is That The Go Through The Teleporter Into The Lobby And Annoy The People In The Lobby. Can Someone Help Me Make A Filtering System. (Also I Didn't Make The Teleport Part Of The Script)
local Teleport = "Lentilkac58-Easy-Teleport-2" --Put the name of the Part between the ""s. function Touch(hit) --Indicates that the Part has been Touched. if script.Parent.Locked == false and script.Parent.Parent:findFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:findFirstChild(Teleport).Locked = true --Checks Debounce. local Pos = script.Parent.Parent:findFirstChild(Teleport) --Gets the Part to teleport to. hit.Parent:moveTo(Pos.Position) wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(Teleport).Locked = false end end --Takes you there and Ends the Function. script.Parent.Touched:connect(Touch) --Listens out for Touchers.
As I can understand is that you don't want NPCs to go through the teleporter. That is easy to handle, just add this code:
for i, plr in ipairs(game.Players:GetChildren()) do if hit.Parent.Name == plr.Name then --Continue here break else print("Not a player!") end end
I wrote this on mobile and did not test this, so it may have errors. If it does, feel free to tell me what the error is.