I have a game where customers will walk up to your smoothie shop’s counter and order something. I use MoveTo to get these NPC’s where they need to go. Often times, they simply stay put outside the restaurant and never walk in. They still order even though my script contains MoveToFinished:Wait()… They think they’re moving, but they don’t? I don’t want to use tweens as it requires some tricky stuff and might take away the ‘immersiveness’ of the experience. (Also because MoveTo is supposed to work anyway)
– Code here
local customer = nil
local player = game.Players.PlayerAdded:Wait()
local TS = game:GetService("TweenService")
local customers = game.ServerStorage.Customers:GetChildren()
local starts = {"hmm.. dunno what i want yet..", "lovely day for a smoothie, huh?", "surprising this place is open 24 hours.",
"i'm tired.. sure something on your menu will wake me up.", "this place is open 24 hours? i could never.",
"hi there!", "everything looks good..", "hmm.. do you have any recommendations?", "i look like i'm thinking but i already know what i want.",
"what's up?", "this place looks fancy.", "what is up??", "i'm in the mood for a DELICIOUS SMOOTHIE!!", "require smoothie i do."
}
local orders = {"Empty Cup", "Banana Smoothie", "Apple Smoothie", "Strawberry Smoothie",
"Pineapple Smoothie", "Chopped Banana Smoothie",
"Chopped Apple Smoothie", "Chopped Pineapple Smoothie", "Chopped Chopped Pineapple Smoothie", "Chopped Apple",
"Pineapple Milkshake", "Chopped Strawberry Milkshake", "Chopped Chopped Banana Milkshake", "Chopped Empty Cup Milkshake"
}
local endings = {"thank you kindly.", "have a nice day.", "nice doing business with you!", "this is the best day of my WHOLE LIFE.",
"surprisingly nice service, i'll come back tommorrow.", "maybe i'll come back.", "thanks!", "that was quick.",
"THIS SERVICE IS BETTER THAN UNICORNS AND RAINBOWS!!!!", "keep the change."
}
local fails = {"should i just come back tommorrow?", "this isn't what i ordered..", "not quite..", "wow. great. i'm so happy.",
"close enough..", "seriously? i used to come here all the time.", "this is the worst day of my WHOLE LIFE.",
"never again shall i enter the sorrowing pit that is this smoothie prison.", "do i deserve this?"
}
local CS = game:GetService("Chat")
local function CustomerWalkTo(coordinates)
local tween = TS:Create(customer.HumanoidRootPart, TweenInfo.new(customer.Humanoid.WalkSpeed, Enum.EasingStyle.Linear),
{ CFrame = coordinates}
)
tween:Play()
walktrack:Play()
tween.Completed:Wait()
walktrack:Stop()
end
local function chat(part, msg)
CS:Chat(part, msg, Enum.ChatColor.Blue)
part.bass:Play()
end
local function setbeam(boolean)
for i, v in pairs(game.Workspace.OrderBeam:GetChildren()) do
if v:IsA("Beam") then
v.Enabled = boolean
end
end
end
local function waituntilplace(order)
while true do
game.Workspace.OrderBeam.ProximityPrompt.Triggered:Wait()
local itemfound = player.Character:FindFirstChild(order)
if itemfound then
itemfound.Parent = game.Workspace.InBeam
itemfound.Handle.CFrame = CFrame.new(-8.325, 4.278, -0.192)
itemfound.Handle.Anchored = true
task.wait(0.1)
game.Workspace.OrderBeam.ProximityPrompt.Enabled = false
game.Workspace.DeskBell.ClickPart.ClickDetector.MouseClick:Wait()
return true
elseif not itemfound and player.Character:FindFirstChildOfClass("Tool") then
local item2 = player.Character:FindFirstChildOfClass("Tool")
item2.Parent = game.Workspace.InBeam
item2.Handle.CFrame = CFrame.new(-8.325, 4.278, -0.192)
item2.Handle.Anchored = true
game.Workspace.OrderBeam.ProximityPrompt.Enabled = false
game.Workspace.DeskBell.ClickPart.ClickDetector.MouseClick:Wait()
game.SoundService.Fail:Play()
return false
end
end
end
setbeam(false)
while true do
task.wait(5)
local failed = false
customer = customers[math.random(1, #customers)]
local Humanoid = customer.Humanoid
walktrack = Humanoid.Animator:LoadAnimation(script.Walk)
thinktrack = Humanoid.Animator:LoadAnimation(script.Think)
paytrack = Humanoid.Animator:LoadAnimation(script.Pay)
holdtrack = Humanoid.Animator:LoadAnimation(script.HoldDrink)
customer.Parent = game.Workspace
customer.Humanoid:MoveTo(Vector3.new(-13.607, 3.939, -0.362))
walktrack:Play()
game.SoundService.SFX.Bell:Play()
customer.Humanoid.MoveToFinished:Wait()
walktrack:Stop()
customer.LookAtPlayer.Enabled = true
task.wait(2)
chat(customer.Head, starts[math.random(1, #starts)])
thinktrack:Play()
task.wait(3)
local order = orders[math.random(1, #orders)]
thinktrack:Stop()
setbeam(true)
chat(customer.Head, "i'll take a "..order..", please.")
game.Workspace.OrderBeam.Ordering.Value = true
game.Workspace.OrderBeam.ProximityPrompt.Enabled = true
if waituntilplace(order) == true then
game.Workspace.OrderBeam.Ordering.Value = false
task.wait(0.1)
game.Workspace.OrderBeam.ProximityPrompt.Enabled = false
chat(customer.Head, endings[math.random(1, #endings)])
local toolinbeam = game.Workspace.InBeam:FindFirstChildOfClass("Tool")
toolinbeam.Handle.Anchored = false
toolinbeam.Parent = customer
holdtrack:Play()
game.ReplicatedStorage.Served:FireClient(player)
setbeam(false)
paytrack:Play()
paytrack.Stopped:Wait()
game.ServerStorage.PaidCash.Parent = game.Workspace
game.Workspace.PaidCash.Collect:Play()
customer.Head.yummy:Play()
task.spawn(function()
task.wait(2)
game.Workspace.PaidCash.Parent = game.ServerStorage
end)
else
failed = true
game.Workspace.OrderBeam.Ordering.Value = false
task.wait(0.1)
game.Workspace.OrderBeam.ProximityPrompt.Enabled = false
chat(customer.Head, fails[math.random(1, #fails)])
game.Workspace.InBeam:FindFirstChildOfClass("Tool"):Destroy()
customer.Head.AnswerGui.Wrong.ImageTransparency = 0
setbeam(false)
end
customer.LookAtPlayer.Enabled = false
customer.Humanoid:MoveTo(Vector3.new(-71.412, 3.939, -0.362))
walktrack:Play()
customer.Humanoid.MoveToFinished:Wait()
customer.Parent = game.ServerStorage.Customers
customer.Head.AnswerGui.Wrong.ImageTransparency = 1
if failed == false then
customer:FindFirstChildOfClass("Tool"):Destroy()
end
holdtrack:Stop()
walktrack:Stop()
task.wait(0.5)
walktrack:Destroy()
paytrack:Destroy()
holdtrack:Destroy()
thinktrack:Destroy()
end