--BROUGHT TO YOU BY RobloxScripter.com!--
local MotiveMin = 95 -- How much motivation is needed to put worker on break
local MotiveMax = 100 -- How much motivation is needed to put worker back to work
local plr = game.Players.LocalPlayer
local Tycoons = workspace.Tycoons:GetChildren()
local WorkerOptions = game:GetService("ReplicatedStorage").Events.WorkerOptions
if not getgenv().Connections then
getgenv().Connections = {}
print('Made connections')
else
for i, v in pairs(getgenv().Connections) do
v:Disconnect()
print('Disconnected')
end
getgenv().Connections = {}
end
function GetTycoon()
local t, tt
for i, v in pairs(workspace.Tycoons:GetChildren()) do
if v.Player.Value == plr then
t = v
tt = true
break
else
t = false
tt = false
end
end
return { t, tt }
end
local Tycoon
print('Waiting for tycoon')
while not Tycoon do
local t = GetTycoon()
if t[2] then
Tycoon = t[1]
end
wait(0.1) -- Wait for a short interval before checking again
end
local Workers = Tycoon.Workers:GetChildren()
for i, worker in pairs(Workers) do
local MotiveVal = worker.Motivation
table.insert(getgenv().Connections, MotiveVal.Changed:Connect(function()
if MotiveVal.Value = MotiveMax then
WorkerOptions:FireServer("PutOnBreak", worker.Name, false)
end
end))
end