So i’m trying to create like a roblox version of idle miner tycoon, then it’s the thing where I need to make sure it doesn’t take more than the capacity of the elevator. It’s kinda weird but I hope it works.
This is the ui: I think you understand the concept.
The local script:
Elevator.Click.MouseButton1Click:Connect(function()
if activeElev == false then
activeElev = true
while activeElev == true do
Elevator.Time.BackgroundColor3 = Color3.fromRGB(118, 157, 116)
Elevator:TweenPosition(
UDim2.new(0.055, 0, 0.417, 0), -- Starting pos | 0.055, 0, 0.2, 0
"InOut",
"Quad",
0.5,
false
)
wait(0.5)
Elevator.Time.BackgroundColor3 = Color3.fromRGB(157, 113, 37)
local shaftStorage = Shaft1.Storage.Value
if Elevator.Capacity.Value >= Elevator.Stored.Value then
local available = (Elevator.Capacity.Value - Elevator.Stored.Value)
local taking = (Shaft1.Storage.Value - available)
Shaft1.Storage.Value -= available
Elevator.Stored.Value += available
local abbreviated = AbbreviationModule:AbbreviateNumbers(tostring(Elevator.Capacity.Value))
local abbreviated2 = AbbreviationModule:AbbreviateNumbers(tostring(Elevator.Stored.Value))
Elevator.CapacityTxt.Text = abbreviated2.."/"..abbreviated
end
wait(1)
Elevator.Time.BackgroundColor3 = Color3.fromRGB(118, 157, 116)
Elevator:TweenPosition(
UDim2.new(0.055, 0, 0.2, 0), -- Starting pos | 0.055, 0, 0.2, 0
"InOut",
"Quad",
0.5,
false
)
wait(0.5)
Elevator.Time.BackgroundColor3 = Color3.fromRGB(157, 113, 37)
wait(0.5)
plr.hiddenstats.bronze.Value += shaftStorage
Elevator.Stored.Value = 0
local abbreviated = AbbreviationModule:AbbreviateNumbers(tostring(Elevator.Capacity.Value))
Elevator.CapacityTxt.Text = "0/"..abbreviated
wait(0.5)
Elevator.Time.BackgroundColor3 = Color3.fromRGB(157, 93, 93)
activeElev = false
wait(0.25)
end
end
end)
So I believe that this would work but right now it just confuses me…
Any help appreciated.