I fixed the leaderstats by the way:
--//Created By Dusty Himself
--Variables//
local Players = game:GetService("Players")
local Humanoid = script.Parent.Humanoid
local humanoidRootPart = script.Parent:FindFirstChild("HumanoidRootPart")
local pfs = game:GetService("PathfindingService")
local Customer = script.Parent
local PlayerValue = script.Player
local Points = game.Workspace.Points
local chair = Points:GetChildren()
local random = math.random(1, 2)
local chosenChair = chair[random]
local BackHome = game.Workspace.BackHome
local path = pfs:CreatePath()
local walkAnim = Humanoid:LoadAnimation(script.Walk)
local emote = Humanoid:LoadAnimation(script.Emote)
local animPlaying = false
local prompt = Customer.GiveCutPrompt
local starterGui = game:GetService("StarterGui")
local popups = starterGui.PopUp
local CashPopUp = popups.CashPopUp
local CashNumberPopUp = CashPopUp.CashNumber
local CashNumberPopUpBG = CashPopUp.CashNumber.BGHowMuchPay
local replicatedStorage = game.ReplicatedStorage
local MoneySound = script["Money Sound"]
local CompletionSound = script["CompletionSound"]
local popUp = CashNumberPopUp.Parent
--Creating Going to chair Path //
--Animations
if animPlaying == false then
walkAnim:Play()
end
if animPlaying == false then
emote:Play()
end
local function Jump()
Customer.Humanoid.Jump = true
end
--Functions//
function GoToChair()
path:ComputeAsync(humanoidRootPart.Position, chosenChair.Position)
for _, waypoint in pairs(path:GetWaypoints()) do
Customer.Humanoid:MoveTo(waypoint.Position)
if animPlaying == false then
walkAnim:Play()
animPlaying =true
end
Customer.Humanoid.MoveToFinished:Wait()
end
end
--Creating the leaaving path
function GoToHome()
path:ComputeAsync(humanoidRootPart.Position, BackHome.Position)
for _, waypoint in pairs(path:GetWaypoints()) do
Customer.Humanoid:MoveTo(waypoint.Position)
if animPlaying == false then
walkAnim:Play()
animPlaying = true
prompt.Enabled = false
end
Customer.Humanoid.MoveToFinished:Wait()
end
end
prompt.Triggered:Connect(function(player)
local leaderstats2 = player:WaitForChild("leaderstats", 1)
local Cash = leaderstats2:WaitForChild("Cash", 1)
local ChosenNumber = math.random(6,30)
local addedAmount = replicatedStorage.AddedAmount
local addedAmountBG = replicatedStorage.AddedAmountBG
wait()
addedAmount.Value = ChosenNumber
addedAmountBG.Value = ChosenNumber
Cash.Value = Cash.Value + ChosenNumber
end)
prompt.TriggerEnded:Connect(function(player)
wait(.15)
CompletionSound:Play()
MoneySound:Play()
emote:Play()
prompt.Enabled = true
wait(1.7)
prompt.Enabled = false
walkAnim:Play()
GoToHome()
wait(2)
Customer:Remove()
end)
--Functions in action//
wait(1)
walkAnim:Play()
GoToChair()
prompt.Enabled = true
PlayerValue:GetPropertyChangedSignal("Value"):Connect(function()
if PlayerValue.Value:IsA("Player") then
game:GetService("ReplicatedStorage").EnablePromptEvent:FireClient(PlayerValue.Value, PlayerValue.Parent.Parent.GiveCutPrompt)
end
end)
PlayerValue.Value = game.Players:GetPlayers()[math.random(#game.Players:GetPlayers())]
print("WentToChair")
walkAnim:Stop()