-
I am trying to make a Start Job button and an End Job button, but I can’t seem the get the code working.
-
The Issue is that I can get it to start counting but the End Job button doesn’t end the counting.
START JOB SCRIPT v
local repFirst = game:GetService("ReplicatedFirst")
local button = script.Parent
local boolValue = repFirst.MoneyGenBool.Value
local counterValue = script.Parent.Parent.CounterValue
counterValue:GetPropertyChangedSignal("Value"):Connect(function()
button.Text = tostring(counterValue.Value)
end)
button.MouseButton1Click:Connect(function()
while boolValue == true do
counterValue.Value = counterValue.Value + 1
task.wait(1)
end
end)
STOP JOB SCRIPT v
local button = script.Parent
local repFirst = game:GetService("ReplicatedFirst")
local bool = repFirst.MoneyGenBool
button.MouseButton1Click:Connect(function()
if bool then
bool.Value = false
end
end)
What my START JOB SCRIPT is doing is it starts counting while a boolValue is set to true, and my STOP JOB SCRIPT sets the boolValue to false when clicked.
I found the boolValue can only be changed via script inside ReplicatedFirst so that’s where I put it.