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

Help Making FNaF Animatronic Movement Script?

Asked by 2 years ago

I've been trying to do this for a week but there are just too many flaws to count and it's not working. Right now, it teleports the animatronics to different part's cframes randomly, which is what I want. Sadly, I am having lots of trouble trying to make it so the animatronics do not move on top of one another. I am also having trouble tracking their positions. For example, I want it so that when they are at the near door position and you turn the light on, it plays a sound. This does not work. I would really like help with this as I've always wanted to make a fnaf game of my own.

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

        while wait(math.random(5, 10)) do
            local whomoves = math.random(1, 4)
            local animetronicmoving
            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
            local position = math.random(1, 12)
            if position == 1 then
                animetronicmoving.HumanoidRootPart.CFrame = offstageright.CFrame            
            elseif position == 2 then
                animetronicmoving.HumanoidRootPart.CFrame = offstageleft.CFrame
            elseif position == 3 then
                animetronicmoving.HumanoidRootPart.CFrame = rightstagecorner.CFrame
            elseif position == 4 then
                animetronicmoving.HumanoidRootPart.CFrame = leftstagecorner.CFrame
            elseif position <=5 then
                animetronicmoving.HumanoidRootPart.CFrame = bydoorleft.CFrame
                game:GetService("ReplicatedStorage").LLight.Changed:Connect(function()
                    if game:GetService("ReplicatedStorage").LLight.Value == true then
                        script.Spotted:Play()
                    end
                end)
            elseif position <= 8 then
                animetronicmoving.HumanoidRootPart.CFrame = bydoorright.CFrame
                game:GetService("ReplicatedStorage").RLight.Changed:Connect(function()
                    if game:GetService("ReplicatedStorage").RLight.Value == true then
                        script.Spotted:Play()
                    end
                end)
            elseif position == 11 then
                animetronicmoving.HumanoidRootPart.CFrame = nearcloset.CFrame
            elseif position == 12 then
                animetronicmoving.HumanoidRootPart.CFrame = counter.CFrame
            end
        end
    end
end)
0
I'm not even sure I'm doing this right but nobody else i've found has posted anything about this subject. parkboy99 20 — 2y

Answer this question