I have these 2 script segments
1:
function employeeJumpscare()
repeat
task.wait()
until awaitEnding == true
awaitEnding = false
player.Character.Humanoid.WalkSpeed = walkSpeed
player.Character.Humanoid.JumpHeight = 6
event:FireClient(player, "Go to the staff room and clock in", "show")
local newHighlite = Instance.new("Highlight", game.Workspace.Important.StaffRoomDoorFrame)
newHighlite.FillTransparency = 1
local alexAi = game.ReplicatedStorage.AlexWorker
progressionConnection = game.Workspace.Important.TriggerEmployeeScare.Touched:Connect(function(hit)
if hit and hit.Parent:FindFirstChild("Humanoid") and JumpsacreEmployeeDB == false then
JumpsacreEmployeeDB = true
newHighlite:Destroy()
event:FireClient(player, "empty", "hide")
game.SoundService.EmployeeJumpscareSound:Play()
player.Character.Humanoid.WalkSpeed = 0
player.Character.Humanoid.JumpHeight = 6
game.Workspace.Important.TriggerEmployeeScare:Destroy()
alexAi.Parent = game.Workspace.Important
game.ReplicatedStorage.TweenCamera:FireClient(player, game.Workspace.Important.EmployeeJumpscareCamera)
local animationTrackWave = alexAi.Humanoid.Animator:LoadAnimation(alexAi.Jumpscare)
animationTrackWave:Play()
animationTrackWave:GetMarkerReachedSignal("Pause"):Connect(function()
animationTrackWave:AdjustSpeed(0)
end)
Ui(player, EmployeeScare.Conversation, 1)
task.wait(1.5)
alexAi.HumanoidRootPart:SetNetworkOwner(nil)
animationTrackWave:Stop()
task.wait(0.6)
alexAi.HumanoidRootPart.CFrame = game.Workspace.Important.AlexTPCFrame.CFrame
repeat task.wait()
until awaitEnding == true
awaitEnding = false
task.wait(0.5)
local path = generatePath(alexAi.HumanoidRootPart, game.Workspace.Important.JumpscareExitWalkTo.Position)
local WalkAnimation = game.ReplicatedStorage.Walk:Clone()
local animLoad = alexAi.Humanoid.Animator:LoadAnimation(WalkAnimation)
animLoad:Play()
game.ReplicatedStorage.TweenCamera:FireClient(player, "reset")
player.Character.Humanoid.WalkSpeed = walkSpeed
player.Character.Humanoid.JumpHeight = 6
if path.Status == Enum.PathStatus.Success then
animLoad:Play()
for _, waypoint in pairs(path:GetWaypoints()) do
alexAi.Humanoid:MoveTo(waypoint.Position)
alexAi.Humanoid.MoveToFinished:Wait()
end
else
warn("Pathfinding failed")
end
animLoad:Stop()
alexAi:Destroy()
local await = ThoughtRemoteFunction:InvokeClient(player, ThoughgtModule.AlexStatementRemarks)
task.wait(5)
progressionConnection:Disconnect()
local await = SpawnCustomerManager("FirstCustomer")
task.wait(2)
local await = SpawnCustomerManager("SecondCustomer")
task.wait(2)
cleanStore()
end
end)
end
2:
function customerSpawn(dialogue)
local spotParkedOn = SpawnCar.Park()
print(spotParkedOn)
local randNpc = game.ReplicatedStorage.NPCS:FindFirstChild("1"):Clone()
randNpc.Parent = game.Workspace
local description = game.Players:GetHumanoidDescriptionFromUserId(PossibleNPCAvatars[math.random(1, #PossibleNPCAvatars)])
randNpc.Humanoid:ApplyDescription(description)
randNpc.Humanoid.DisplayDistanceType = "None"
randNpc.HumanoidRootPart.CFrame = game.Workspace.ParkingSpots:FindFirstChild(spotParkedOn).CFrame + Vector3.new(0, 5, 0)
task.wait(1)
local WalkAnimation = game.ReplicatedStorage.Walk
local animLoad = randNpc.Humanoid.Animator:LoadAnimation(WalkAnimation)
local path = generatePath(randNpc.HumanoidRootPart, CustomerWalkTo.Position)
randNpc.HumanoidRootPart:SetNetworkOwner(nil)
task.wait(1)
if path.Status == Enum.PathStatus.Success then
animLoad:Play()
print("pathfinding succesful")
for i, waypoint in pairs(path:GetWaypoints()) do
randNpc.Humanoid:MoveTo(waypoint.Position)
randNpc.Humanoid.MoveToFinished:Wait()
end
--local humanoidRootPart = player.character:WaitForChild("HumanoidRootPart")
randNpc.HumanoidRootPart.CFrame = CFrame.new(randNpc.HumanoidRootPart.Position, randNpc.HumanoidRootPart.Position + (game.Workspace.Important.CashRegister1.Position-randNpc.HumanoidRootPart.Position).Unit)
animLoad:Stop()
customerOrder(randNpc.Head, dialogue)
end
end
In segment 2 the walk animation never plays despite both rigs being r15 and using the exact same animation.
Another issue I have is that in segment one the 0.6 second wait is necessary as without it the npc would randomly get flinged, I do not like having the wait as it adds a noticeable delay where the AI is not in the correct position