local function cleanStainsFires()
if workspace:FindFirstChild("Stains") then
workspace.Stains:Destroy()
end
if workspace:FindFirstChild("Fires") then
workspace.Fires:Destroy()
end
end
--TRUCK JOB
local canCarrySupply = true
local function showRandomTarget(toggle)
if toggle == true then
local getRandomTarget = MallSupplier.truckShops:GetChildren()[math.random(1,#MallSupplier.truckShops:GetChildren())]
local helper = getRandomTarget.Info
local clicker = getRandomTarget.Clicker
getRandomTarget.Transparency = 0
helper.Enabled = true
clicker.Enabled = true
clicker.Triggered:Connect(function(player)
if canCarrySupply == false then
canCarrySupply = true
--invisible the item
helper.Enabled = false
clicker.Enabled = false
getRandomTarget.Transparency = 1
--give player cash
jobRemotes:WaitForChild("clientEarnJobMoney"):FireServer("Mall Supplier")
--after all finished, return success
end
end)
else
for t,k in pairs(MallSupplier.truckShops:GetChildren()) do
k.Info.Enabled = false
k.Clicker.Enabled = false
k.Transparency = 1
end
end
--if finishedJob == true then
-- --finishedJob = false
-- return "Success"
--end
end
local function handleTruck(toggle)
if toggle == true then
for index,value in pairs(mallTrucks:GetChildren()) do
local infoCard = value:FindFirstChild("Info",true)
local clicker = value:FindFirstChild("clicker",true)
local supplyAmount = value:FindFirstChild("SupplyAmount",true)
local amountText = value:FindFirstChild("jobInfo",true).gui.amountText
clicker.Enabled = true
--Destroying the truck
supplyAmount.Changed:Connect(function(newv)
amountText.Text = newv.."/10"
if newv == 0 then
local getTruck = supplyAmount.Parent
getTruck.Truck.Transparency = 1
getTruck.Truck.CanCollide = false
getTruck.Truck.Info.Enabled = false
getTruck.getSupply.clicker.Enabled = false
getTruck.getSupply.gui.Enabled = false
getTruck.jobInfo.gui.Enabled = false
spawn(function()
task.wait(40)
if CurrentJob.Value == "Mall Supplier" then
getTruck.Truck.Transparency = 0
getTruck.Truck.CanCollide = true
getTruck.Truck.Info.Enabled = true
getTruck.getSupply.clicker.Enabled = true
getTruck.getSupply.gui.Enabled = true
getTruck.jobInfo.gui.Enabled = true
end
getTruck.SupplyAmount.Value = 10
end)
end
end)
clicker.Triggered:Connect(function(player)
print(canCarrySupply)
if supplyAmount.Value > 0 then
if canCarrySupply then
canCarrySupply = false
supplyAmount.Value -= 1
showRandomTarget(true)
--local getResult = showRandomTarget()
--if getResult == "Success" then
-- canCarrySupply = true
--end
end
end
end)
infoCard.Enabled = true
end
else
for index,value in pairs(mallTrucks:GetChildren()) do
local infoCard = value:FindFirstChild("Info",true)
local clicker = value:FindFirstChild("clicker",true)
infoCard.Enabled = false
clicker.Enabled = false
end
canCarrySupply = true
showRandomTarget(false)
end
end
-- TRUCK JOB
leaderstats.CurrentJob.Changed:Connect(function(val)
if val == "Mall Supplier" then
cleanStainsFires()
handleTruck(true)
elseif val == "Street Cleaner" then
local stains = jobStuff:WaitForChild("Stains"):Clone()
handleTruck(false)
if workspace:FindFirstChild("Stains") then return end
stains.Parent = workspace
if workspace:FindFirstChild("Fires") then
workspace.Fires:Destroy()
end
elseif val == "FDNY" then
local stains = jobStuff:WaitForChild("Fires"):Clone()
handleTruck(false)
if workspace:FindFirstChild("Fires") then return end
stains.Parent = workspace
if workspace:FindFirstChild("Stains") then
workspace.Stains:Destroy()
end
else
handleTruck(false)
cleanStainsFires()
end
end)
if CurrentJob.Value == "Street Cleaner" then
local stains = jobStuff:WaitForChild("Stains"):Clone()
if workspace:FindFirstChild("Stains") then return end
stains.Parent = workspace
elseif CurrentJob.Value == "FDNY" then
local stains = jobStuff:WaitForChild("Fires"):Clone()
if workspace:FindFirstChild("Fires") then return end
stains.Parent = workspace
elseif CurrentJob.Value == "Mall Supplier" then
handleTruck(true)
end
local script
