Technically, this code works fine. But it’s really ugly to look at and I feel like it can be more optimized, as well as run off on a more dynamic number system. Any ideas or pointers would be amazing! Thank you
local RefillEvent = game.ReplicatedStorage.Refill
local fill1 = script.Parent:WaitForChild('fill1')
local fill2 = script.Parent:WaitForChild('fill2')
local fill3 = script.Parent:WaitForChild('fill3')
local fill4 = script.Parent:WaitForChild('fill4')
local fill5 = script.Parent:WaitForChild('fill5')
local fill6 = script.Parent:WaitForChild('fill6')
local fill7 = script.Parent:WaitForChild('fill7')
local FillVal = script.Parent.FillVal
-- This is some real impractical yandere dev code
FillVal.Changed:connect(function()
if FillVal.Value <= 0 then
FillVal.Value = 0
fill1.Transparency = 1
fill2.Transparency = 1
fill3.Transparency = 1
fill4.Transparency = 1
fill5.Transparency = 1
fill6.Transparency = 1
fill7.Transparency = 1
elseif FillVal.Value == 1 then
fill1.Transparency = 0
fill2.Transparency = 1
fill3.Transparency = 1
fill4.Transparency = 1
fill5.Transparency = 1
fill6.Transparency = 1
fill7.Transparency = 1
elseif FillVal.Value == 2 then
fill1.Transparency = 1
fill2.Transparency = 0
fill3.Transparency = 1
fill4.Transparency = 1
fill5.Transparency = 1
fill6.Transparency = 1
fill7.Transparency = 1
elseif FillVal.Value == 3 then
fill1.Transparency = 1
fill2.Transparency = 1
fill3.Transparency = 0
fill4.Transparency = 1
fill5.Transparency = 1
fill6.Transparency = 1
fill7.Transparency = 1
elseif FillVal.Value == 4 then
fill1.Transparency = 1
fill2.Transparency = 1
fill3.Transparency = 1
fill4.Transparency = 0
fill5.Transparency = 1
fill6.Transparency = 1
fill7.Transparency = 1
elseif FillVal.Value == 5 then
fill1.Transparency = 1
fill2.Transparency = 1
fill3.Transparency = 1
fill4.Transparency = 1
fill5.Transparency = 0
fill6.Transparency = 1
fill7.Transparency = 1
elseif FillVal.Value == 6 then
fill1.Transparency = 1
fill2.Transparency = 1
fill3.Transparency = 1
fill4.Transparency = 1
fill5.Transparency = 1
fill6.Transparency = 0
fill7.Transparency = 1
elseif FillVal.Value == 7 then
fill1.Transparency = 1
fill2.Transparency = 1
fill3.Transparency = 1
fill4.Transparency = 1
fill5.Transparency = 1
fill6.Transparency = 1
fill7.Transparency = 0
elseif FillVal.Value > 7 then
FillVal.Value = 7
end
end)
Prompt.Triggered:Connect(function(player)
if player.Character:FindFirstChildOfClass('Tool') then
local Tool = player.Character:FindFirstChildOfClass('Tool')
if Tool:GetAttribute("Type") == "Water" then
RefillEvent:FireClient(player)
Prompt.Parent.Drip.PlaybackSpeed = (math.random(1,1.3))
Prompt.Parent.Drip:Play()
end
end
end)