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

How Would I Go About Making a FNaF Script to Move the Animatronics?

Asked by 2 years ago

They teleport just like I want them to, but I can't seem to make it so that they don't teleport to a spot when someone else is there. Any ideas?

game:GetService("ReplicatedStorage").Ready.Changed:Connect(function()
    if game.ReplicatedStorage.Ready.Value == true then
        local riou = workspace.Riou
        local mori = workspace.Mori
        local hina = workspace.Hina
        local asui = workspace.Asui
        local senpai = workspace.Senpai

        local offstageright = workspace.OffstageRight
        local offstageleft = workspace.OffstageLeft
        local rightstagecorner = workspace.StageCornerRight
        local leftstagecorner = workspace.StageCornerLeft
        local bydoorleft = workspace.ByDoorLeft
        local bydoorright = workspace.ByDoorRight
        local nearcloset = workspace.NearCloset
        local counter = workspace.Counter

        local llight = game:GetService("ReplicatedStorage").LLight
        local rlight = game:GetService("ReplicatedStorage").RLight
        local rdoor = game:GetService("ReplicatedStorage").RDoor
        local ldoor = game:GetService("ReplicatedStorage").LDoor

        local p1
        local p2
        local p3
        local p4
        local p5
        local p6
        local p7
        local p8

        local jumpscared = false

        local animetronicmoving
        local upnext = 0

        while wait(math.random(5, 10)) do
            local whomoves = math.random(1, 4)
            if whomoves == 1 then
                animetronicmoving = riou
            elseif whomoves == 2 then
                animetronicmoving = mori
            elseif whomoves == 3 then
                animetronicmoving = hina
            elseif whomoves == 4 then
                animetronicmoving = asui
            end

            if upnext == 1 then
                upnext = 0
                animetronicmoving = p1
            elseif upnext == 2 then
                upnext = 0
                animetronicmoving = p2
            end

            local position = math.random(1, 12)
            if position == 1 then
                animetronicmoving.HumanoidRootPart.CFrame = offstageright.CFrame
                p1 = animetronicmoving
            elseif position == 2 then
                animetronicmoving.HumanoidRootPart.CFrame = offstageleft.CFrame
                p2 = animetronicmoving
            elseif position == 3 then
                animetronicmoving.HumanoidRootPart.CFrame = rightstagecorner.CFrame
                p3 = animetronicmoving
            elseif position == 4 then
                animetronicmoving.HumanoidRootPart.CFrame = leftstagecorner.CFrame
                p4 = animetronicmoving
            elseif position >=5 then
                animetronicmoving.HumanoidRootPart.CFrame = bydoorleft.CFrame
                p5 = animetronicmoving
                print(animetronicmoving)
                while wait() do
                    if llight.Value == true then
                        workspace.Spotted:Play()
                        print("Spotted")
                        upnext = 1
                    end
                    if ldoor.Value == false then
                        wait(1.5)
                        if ldoor.Value == false then
                            print("Jumpscared")
                        end
                    end
                end
            elseif position >= 8 then
                animetronicmoving.HumanoidRootPart.CFrame = bydoorright.CFrame
                p6 = animetronicmoving
                print(animetronicmoving)
                while wait() do
                    if rlight.Value == true then
                        workspace.Spotted:Play()
                        print("Spotted")
                        upnext = 2
                    end
                end
                if rdoor.Value == false then
                    wait(1.5)
                    if rdoor.Value == false then
                        print("Jumpscared")
                    end
                end
            elseif position == 11 then
                animetronicmoving.HumanoidRootPart.CFrame = nearcloset.CFrame
                p7 = animetronicmoving
            elseif position == 12 then
                animetronicmoving.HumanoidRootPart.CFrame = counter.CFrame  
                p8 = animetronicmoving
            end
        end
    end
end)
0
With someone else you mean players or other animatronics? C1RAXY 81 — 2y
0
another animatronic parkboy99 20 — 2y

Answer this question