Hiring Client:
local workersfolder = game.ReplicatedStorage.Workers
local waiter = workersfolder.Waiter
local plr = game.Players.LocalPlayer
local mainframe = plr.PlayerGui.WorkerGUI.Main.WaiterButton.WaitersFrame
local waiter1 = mainframe.Waiter1
local buy = waiter1.BuyButton
local leaderstats = plr:FindFirstChild("leaderstats")
local coins = leaderstats:FindFirstChild("Coins")
local WaiterCost = plr.WaiterCost
buy.MouseButton1Click:Connect(function()
print("Client Value:"..coins.Value)
if coins.Value >= WaiterCost.Value then
local firstName = {
'Noah', 'Sarah', 'Bob', 'Billy', 'Emma', 'Liam', 'Olivia', 'James', 'Sophia', 'Lucas', 'Ava', 'Mia',
'Ethan', 'Isabella', 'Mason', 'Charlotte', 'Logan', 'Amelia', 'Jackson', 'Harper', 'Aiden', 'Evelyn', 'Lucas', 'Abigail',
'Carter', 'Emily', 'Sebastian', 'Madison', 'Elijah', 'Elizabeth', 'Oliver', 'Scarlett', 'Jayden', 'Victoria', 'Henry', 'Chloe',
}
local fn = firstName[math.random(#firstName)]
local lastname = {
'Smith', 'Johnson', 'Brown', 'Davis', 'Wilson', 'Anderson', 'Garcia', 'Martinez', 'Miller', 'Taylor',
'Thomas', 'Jackson', 'White', 'Harris', 'Young', 'Lee', 'Walker', 'Hall', 'Allen', 'King', 'Scott', 'Baker',
}
local ln = lastname[math.random(#lastname)]
if ln == fn then -- IF THEY SOMEHOW ARE THE SAME
fn = firstName[math.random(#firstName)]
ln = lastname[math.random(#lastname)]
print("They were the same, so they were rerolled")
end
game.ReplicatedStorage.Hiring:FireServer(1, fn, ln)
waiter1.NameText.Text = fn .. " " .. ln
buy.Visible = false
waiter1.FrameClick.Visible = true
end
end)
WorkerServer:
game.ReplicatedStorage.Hiring.OnServerEvent:Connect(function(plr,number,firstn,lastn)
print("Sent to the server "..plr.Name.." with number "..number)
local workersfolder = game.ReplicatedStorage.Workers
local waiter = workersfolder.Waiter
local mainframe = plr.PlayerGui.WorkerGUI.Main.WaiterButton.WaitersFrame
local waiter1 = mainframe.Waiter1
local buy = waiter1.BuyButton
local leaderstats = plr:FindFirstChild("leaderstats")
local coins = leaderstats:FindFirstChild("Coins")
local WaiterCost = plr.WaiterCost
local worker = waiter:Clone()
if coins.Value >= WaiterCost.Value then
coins.Value = coins.Value - WaiterCost.Value
WaiterCost.Value = WaiterCost.Value + 250
worker.Parent = workspace
worker.Owner.Value = plr.Name
worker.HumanoidRootPart.CFrame = plr.Character.HumanoidRootPart.CFrame
worker.Name = plr.Name.."_waiter_"..number
worker.Humanoid.DisplayName = "Waiter: "..firstn.." "..lastn
worker.WorkerName.Value = firstn.." "..lastn
end
end)
game.ReplicatedStorage.Firing.OnServerEvent:Connect(function(plr,worker,backAmount)
worker:Destroy()
local leaderstats = plr:FindFirstChild("leaderstats")
local coins = leaderstats:FindFirstChild("Coins")
coins.Value = coins.Value + backAmount
end)
FireClient:
local plr = game.Players.LocalPlayer
local mainframe = plr.PlayerGui.WorkerGUI.Main.WaiterButton.WaitersFrame
local overview = plr.PlayerGui.WorkerGUI.OverView
local fire = overview.FireButton
local numberOfWorker = fire.WorkerPicked
local leaderstats = plr:FindFirstChild("leaderstats")
local coins = leaderstats:FindFirstChild("Coins")
local WaiterCost = plr.WaiterCost
fire.MouseButton1Click:Connect(function()
local workerSelected = plr.Name.."_waiter_"..numberOfWorker.Value
local selectedWorker = workspace[workerSelected]
local waiter = mainframe.Waiter1
if selectedWorker then
local returnAmount = plr.WaiterCost.Value - 1.3 * 100 - 250
print(returnAmount)
coins.Value = coins.Value - returnAmount
game.ReplicatedStorage.Firing:FireServer(selectedWorker,returnAmount)
WaiterCost.Value = 250
print("Cost: "..WaiterCost.Value)
waiter.BuyButton.Visible = true
waiter.NameText.Text = "Waiter "..numberOfWorker.Value
overview.Visible = false
numberOfWorker.Value = 0
waiter.FrameClick.Visible = false
else
warn("Worker not found in the workspace.")
end
end)
On the 5th time of hiring the worker and firing it, it will not spawn in the worker, but it will take my money>? Any idea how to fix
Thanks for the help, Your amazing