Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how do i make an enemy teleport?

Asked by
omorizz 50
2 years ago
Edited 2 years ago

i have this teleporting door script (it fades in and out, works perfectly for normal players) but it won't teleport an enemy, or npc. the npc/enemy has a humanoid (it's the drooling zombie made by roblox) this is the teleport script

local TeleportationDoorEvent = game.ReplicatedStorage.TeleportationDoorEvent

local Door1 = script.Parent.Door1 
local Door2 = script.Parent.Door2

local debounce = false




Door1.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        if not debounce then
            debounce = true

            local plr = game.Players:GetPlayerFromCharacter(hit.Parent)

            if plr then
                TeleportationDoorEvent:FireClient(plr)
                wait(0.8)
                hit.Parent.HumanoidRootPart.CFrame = Door2.CFrame
                wait(2)
                debounce = false
            end
        end
    end
end)




-- (door 2 is removed so you can only teleport one way)
0
local TeleportationDoorEvent = game.ReplicatedStorage.TeleportationDoorEvent local Door1 = script.Parent.Door1 local Door2 = script.Parent.Door2 local debounce = false Door1.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then if not debounce then debounce = true hit.Parent.HumanoidRootPart.CFrame = CFrame.new(Door2.CFrame) debounc mkn00b 5 — 2y

2 answers

Log in to vote
0
Answered by 2 years ago
local TeleportationDoorEvent = game.ReplicatedStorage.TeleportationDoorEvent

local Door1 = script.Parent.Door1 
local Door2 = script.Parent.Door2

local debounce = false




Door1.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        if not debounce then
            debounce = true

            local plr = game.Players:GetPlayerFromCharacter(hit.Parent)

            if plr then
                TeleportationDoorEvent:FireClient(plr)
end
                wait(0.8)
                if hit.Parent:FindFirstChild("HumanoidRootPart",true) then
hit.Parent.HumanoidRootPart.CFrame = Door2.CFrame
end
                wait(2)
                debounce = false
            end
        end
    end
end)




-- (door 2 is removed so you can only teleport one way)

Maybe This Will work

Ad
Log in to vote
0
Answered by
mkn00b 5
2 years ago

this will make you teleporting to door2 when door1 has been touched


local TeleportationDoorEvent = game.ReplicatedStorage.TeleportationDoorEvent local Door1 = script.Parent.Door1 local Door2 = script.Parent.Door2 local debounce = false Door1.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then if not debounce then debounce = true hit.Parent.HumanoidRootPart.CFrame = CFrame.new(Door2.CFrame) debounce = false end end end end)

Answer this question