Okay, here’s my code.
local TweenService = game:GetService("TweenService")
local TeleportService = game:GetService("TeleportService")
local animatronic = script.Parent
local humanoid = animatronic:WaitForChild("Humanoid")
local HRP = animatronic:WaitForChild("HumanoidRootPart")
local rightDoorValue = game.ReplicatedStorage:WaitForChild("Values").RightDoor
local camerasValue = game.ReplicatedStorage:WaitForChild("Values").Cameras
local lookForwardEvent = game.ReplicatedStorage:WaitForChild("LookForwardEvent")
local moveSound = game.SoundService:WaitForChild("MoveSound")
local jumpscareSound = game.SoundService:WaitForChild("JumpscareSound")
local moveableCameras = {
cam1A = Vector3.new(0.7, 6.92, -65.9),
cam1B = Vector3.new(0, 5.92, -41.4),
cam4A = Vector3.new(6, 5.92, -9.9),
cam4B = Vector3.new(3.6, 5.92, 18.2),
cam6 = Vector3.new(14.7, 5.92, -16),
cam7 = Vector3.new(22.9, 5.92, -53.5),
attackPos = Vector3.new(2.341, 5.92, 4.391)
}
local animations = {
stagePose = script.Parent.StagePose,
diningRoomPose = script.Parent.DiningRoomPose,
restroomPose = script.Parent.RestroomPose,
hallPose = script.Parent.HallPose,
cornerPose = script.Parent.CornerPose,
attackPose = script.Parent.AttackPose,
jumpscare = script.Parent.Jumpscare
}
local animationTracks = {
stagePoseTrack = humanoid:LoadAnimation(animations.stagePose),
diningRoomPoseTrack = humanoid:LoadAnimation(animations.diningRoomPose),
restroomPoseTrack = humanoid:LoadAnimation(animations.restroomPose),
hallPoseTrack = humanoid:LoadAnimation(animations.hallPose),
cornerPoseTrack = humanoid:LoadAnimation(animations.cornerPose),
attackPoseTrack = humanoid:LoadAnimation(animations.attackPose),
jumpscareTrack = humanoid:LoadAnimation(animations.jumpscare)
}
local function CAM1BMove()
HRP.Position = moveableCameras.cam1B
HRP.Orientation = Vector3.new(0, 90, 0)
end
local function CAM4AMove()
HRP.Position = moveableCameras.cam4A
HRP.Orientation = Vector3.new(0, -180, 0)
end
local function CAM4BMove()
HRP.Position = moveableCameras.cam4B
HRP.Orientation = Vector3.new(0, 0, 0)
end
local function CAM6Move()
HRP.Position = moveableCameras.cam6
HRP.Orientation = Vector3.new(0, 90, 0)
end
local function CAM7Move()
HRP.Position = moveableCameras.cam7
HRP.Orientation = Vector3.new(0, 45, 0)
end
local function JumpscareMove(player)
HRP.Position = Vector3.new(-6, -3.68, 8.8)
HRP.Orientation = Vector3.new(0, -180, 0)
TweenService:Create(HRP, TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.In), {Position = Vector3.new(-6, 5.22, 8.8)}):Play()
wait(0.4)
animationTracks.jumpscareTrack:Play()
jumpscareSound:Play()
wait(0.5)
player.PlayerGui.GameOverGui.Enabled = true
jumpscareSound.Ended:Connect(function()
TeleportService:Teleport(13882586605, player)
end)
end
local function movement(player)
local playerGui = player:WaitForChild("PlayerGui")
local videoStatic = playerGui:WaitForChild("CameraGui").VideoStatic.VideoTransparency
moveSound:Play()
if camerasValue.Value == true then
videoStatic.Transparency = NumberSequence.new(0)
wait(1)
videoStatic.Transparency = NumberSequence.new(0.8)
end
if HRP.Position == moveableCameras.cam1A then
CAM1BMove()
animationTracks.diningRoomPoseTrack:Play()
wait(math.random(30, 60))
animationTracks.diningRoomPoseTrack:Stop()
movement(player)
elseif HRP.Position == moveableCameras.cam1B then
local rng = math.random(1, 3)
if rng == 1 then
CAM7Move()
animationTracks.restroomPoseTrack:Play()
wait(math.random(30, 60))
animationTracks.restroomPoseTrack:Stop()
movement(player)
elseif rng == 2 then
CAM6Move()
wait(math.random(30, 60))
movement(player)
elseif rng == 3 then
CAM4AMove()
animationTracks.hallPoseTrack:Play()
wait(math.random(30, 60))
animationTracks.hallPoseTrack:Stop()
movement(player)
end
elseif HRP.Position == moveableCameras.cam4A then
CAM4BMove()
animationTracks.cornerPoseTrack:Play()
wait(math.random(30, 60))
animationTracks.cornerPoseTrack:Stop()
movement(player)
elseif HRP.Position == moveableCameras.cam4B then
HRP.Position = moveableCameras.attackPos
HRP.Orientation = Vector3.new(0, 112.5, 0)
animationTracks.attackPoseTrack:Play()
wait(math.random(10, 15))
animationTracks.attackPoseTrack:Stop()
if rightDoorValue.Value == false then
lookForwardEvent:FireClient(player)
JumpscareMove(player)
elseif rightDoorValue.Value == true then
local rng = math.random(1, 2)
if rng == 1 then
CAM7Move()
animationTracks.restroomPoseTrack:Play()
wait(math.random(30, 60))
animationTracks.restroomPoseTrack:Stop()
movement(player)
elseif rng == 2 then
CAM6Move()
wait(math.random(30, 60))
movement(player)
elseif rng == 3 then
CAM1BMove()
animationTracks.diningRoomPoseTrack:Play()
wait(math.random(30, 60))
animationTracks.diningRoomPoseTrack:Stop()
movement(player)
end
end
elseif HRP.Position == moveableCameras.cam6 then
CAM1BMove()
animationTracks.diningRoomPoseTrack:Play()
wait(math.random(30, 60))
animationTracks.diningRoomPoseTrack:Stop()
movement()
elseif HRP.Position == moveableCameras.cam7 then
CAM1BMove()
animationTracks.diningRoomPoseTrack:Play()
wait(math.random(30, 60))
animationTracks.diningRoomPoseTrack:Stop()
movement()
end
end
game.Players.PlayerAdded:Connect(function(player)
animationTracks.stagePoseTrack:Play()
wait(math.random(30, 60))
animatronic.EXLeftHand.Cupcake:Destroy()
animationTracks.stagePoseTrack:Stop()
movement(player)
end)