Hello Everyone! I finally noticed how awful some of my scripting organization was for some of the scripts I have done for my game, so I’ve decided to spend some time making my code more readable and maybe more efficient with some new things I learned.
I fixed up a script I had which created boost displays at the top of your screen to show what boosts you currently had on, and honestly I think I did a good job with making it more organized. I’m just wondering if there is any way I can further improve my script to be either more understandable or more efficient?
My new script, which is done within a module script:
local Bar = {}
local field = script.Parent.Parent.Parent
local TweenService = game:GetService("TweenService")
function Bar.AddDisplay(DisplayType: string, BoostHolder, player: Player)
local WaitTime
local AlreadyDisplaying = false
local DisplayList = { -- Apply new Displays here
["Fire"] = {
["Value"] = "DisplayIsFire";
["DisplayColor"] = Color3.fromRGB(145, 0, 0);
["DurationColor"] = Color3.fromRGB(255, 0, 0);
["Icon"] = BoostHolder.Icons.FireIcon;
["Duration"] = 5;
["Description"] = {
["Title"] = "Fire Boost";
["InfoText1"] = "x1.5 Movement Speed"
}
};
["BoosterX2Cash"] = {
["Value"] = "DisplayIsX2Cash";
["DisplayColor"] = Color3.fromRGB(19, 145, 0);
["DurationColor"] = Color3.fromRGB(35, 255, 50);
["Icon"] = BoostHolder.Icons.BoosterX2CashIcon;
["Duration"] = 10;
["Description"] = {
["Title"] = "Cash Boost";
["InfoText1"] = "x2 Cash"
}
};
["BoosterAllShiny"] = {
["Value"] = "DisplayIsAllShiny";
["DisplayColor"] = Color3.fromRGB(19, 145, 0);
["DurationColor"] = Color3.fromRGB(35, 255, 50);
["Icon"] = BoostHolder.Icons.BoosterAllShinyIcon;
["Duration"] = 10;
["Description"] = {
["Title"] = "Shiny Boost";
["InfoText1"] = "Shiny Chance = 100%"
}
};
["BoosterGoldChance"] = {
["Value"] = "DisplayIsGoldChance";
["DisplayColor"] = Color3.fromRGB(19, 145, 0);
["DurationColor"] = Color3.fromRGB(35, 255, 50);
["Icon"] = BoostHolder.Icons.BoosterGoldChanceIcon;
["Duration"] = 10;
["Description"] = {
["Title"] = "Gold Chance Boost";
["InfoText1"] = "x2 Gold Chance"
}
};
["Spacious"] = {
["Value"] = "DisplayIsSpacious";
["DisplayColor"] = Color3.fromRGB(108, 41, 146);
["DurationColor"] = Color3.fromRGB(160, 66, 205);
["Icon"] = BoostHolder.Icons.SpaciousIcon;
["Duration"] = 10;
["Description"] = {
["Title"] = "Force Field";
["InfoText1"] = "Increase Pickup Range"
}
};
["VIP"] = {
["Value"] = "DisplayIsVIP";
["DisplayColor"] = Color3.fromRGB(184, 179, 28);
["DurationColor"] = Color3.fromRGB(244, 255, 42);
["Icon"] = BoostHolder.Icons.CrownIcon;
["Duration"] = 10;
["Description"] = {
["Title"] = "VIP Boost";
["InfoText1"] = "+10% Cash";
["InfoText2"] = "+25% All Rarities"
}
};
}
local function UpdatePositions()
for index, Display in pairs(BoostHolder.DisplayParent:GetChildren()) do
print(index, Display)
Display.Position = UDim2.new(0.052*(index-1), 0, 0, 0)
end
end
local function StartDuration(Display)
Display:WaitForChild("Description"):FindFirstChild("DurationText").Text = WaitTime.."s"
while WaitTime > 0 do
task.wait(1)
WaitTime -= 1
Display:WaitForChild("Description").DurationText.Text = WaitTime.."s"
end
if WaitTime <= 0 and Display then
Display:Destroy()
UpdatePositions()
end
end
local function CreateDisplay(DisplayType)
local Display = BoostHolder.DisplaySample:Clone() -- Create Display
local DisplayValue = Instance.new("StringValue")
DisplayValue.Parent = Display
DisplayValue.Name = "DisplayValue"
Display.Parent = BoostHolder.DisplayParent
Display.Name = "Display"
Display.Visible = true
Display.Size = UDim2.new(0.013, 0, 0.25, 0)
local DurationFrame = BoostHolder.DisplaySample:Clone() -- Create Duration Frame
DurationFrame.Parent = Display
DurationFrame.Name = "DurationBar"
DurationFrame.Visible = true
DurationFrame.Size = UDim2.new(1, 0, 1, 0)
for Type, List in pairs(DisplayList) do
if Type == DisplayType then
DisplayValue.Value = List.Value
Display.ImageColor3, DurationFrame.ImageColor3 = List.DisplayColor, List.DurationColor
Display.Description.BorderColor3 = DurationFrame.ImageColor3
--Set icon
local Icon = List.Icon:Clone()
Icon.Parent = Display
Icon.Visible = true
-- Set description
local InfoFolder = Display.Description.Information
Display.Description:WaitForChild("TitleText").Text = List.Description.Title
for InfoText, str in pairs(List.Description) do
for index, Label in pairs(InfoFolder:GetChildren()) do
if Label.Name == InfoText then
Label.Text = str
end
end
end
local DurationTween = TweenService:Create(DurationFrame, TweenInfo.new(List.Duration, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {Size = UDim2.new(0, 0, 1, 0)})
DurationTween:Play()
if AlreadyDisplaying ~= true then
local ExpandTween = TweenService:Create(Display, TweenInfo.new(0.2, Enum.EasingStyle.Back, Enum.EasingDirection.InOut, 0, false, 0), {Size = UDim2.new(0.052, 0,1, 0)})
ExpandTween:Play()
else
Display.Size = UDim2.new(0.052, 0,1, 0)
end
Display.MouseEnter:Connect(function()
Display.Description.Visible = true -- Open Description Page
end)
Display.MouseLeave:Connect(function()
Display.Description.Visible = false -- Close Description Page
end)
WaitTime = List.Duration
UpdatePositions()
StartDuration(Display, List)
end
end
end
local function CheckforExistingDisplay(DisplayType: string, Type: string)
for _, DisplayFrame in pairs(BoostHolder.DisplayParent:GetChildren()) do
if DisplayFrame:FindFirstChild("DisplayValue") then
if DisplayFrame.DisplayValue.Value == DisplayType then -- If display currently Exists, destroy it
DisplayFrame:Destroy()
AlreadyDisplaying = true
end
end
end
end
if field:FindFirstChild("PlayerOwnerShip") then
for _, player in pairs(game.Players:GetChildren()) do
if player.Name == field.PlayerOwnerShip.Value then
for Type, properties in pairs(DisplayList) do
if DisplayType == Type then
CheckforExistingDisplay(properties.Value, Type)
CreateDisplay(Type)
end
end
end
end
end
end
return Bar
(If anyone wants to see this horrific code) The old script, which was in a server script:
local RunService = game:GetService("RunService")
TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local tweenInfo3 = TweenInfo.new(10, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local tweenInfo2 = TweenInfo.new(0.2, Enum.EasingStyle.Back, Enum.EasingDirection.InOut, 0, false, 0)
local Base = script.Parent.Parent
local EventsFolder = Base.EventsFolder
ADE = EventsFolder.AddDisplayEvent
ADE2 = EventsFolder.AddDisplayEvent2
ADE3 = EventsFolder.AddDisplayEvent3
ADE4 = EventsFolder.AddDisplayEvent4
ADE5 = EventsFolder.AddDisplayEvent5
ADE6 = EventsFolder.AddDisplayEvent6
local FireAlreadyDisplaying = false
local BoostCashAlreadyDisplaying, BoostAllShinyAlreadyDisplaying, BoostGoldChanceAlreadyDisplaying, SpaciousAlreadyDisplaying = false, false, false, false
local VIPAlreadyDisplaying = false
local FireCooldown, FireWaitTime = false, 5
local BoostCashCooldown, BoostCashWaitTime = false, 10
local BoostAllShinyCooldown, BoostAllShinyWaitTime = false, 5
local BoostGoldChanceCooldown, BoostGoldChanceWaitTime = false, 10
local SpaciousCooldown, SpaciousWaitTime = false, 10
local VIPCooldown, VIPWaitTime = false, 10
CallWhileFunction, called = EventsFolder.FireCallWhileFunctionDisplay, false
BoosterCashWhileFunction, called2 = EventsFolder.BoosterCashWhileFunctionDisplay, false
BoosterAllShinyWhileFunction, called3 = EventsFolder.BoosterAllShinyWhileFunctionDisplay, false
BoosterGoldChanceWhileFunction, called4 = EventsFolder.BoosterGoldChanceWhileFunctionDisplay, false
SpaciousCallWhileFunction, called5 = EventsFolder.SpaciousCallWhileFunctionDisplay, false
VIPCallWhileFunction, called6 = EventsFolder.VIPCallWhileFunctionDisplay, false
local function FireEvent()
called = true
CallWhileFunction:Fire()
end
local function BoostCashEvent()
called2 = true
BoosterCashWhileFunction:Fire()
end
local function BoostAllShinyEvent()
called3 = true
BoosterAllShinyWhileFunction:Fire()
end
local function BoostGoldChanceEvent()
called4 = true
BoosterGoldChanceWhileFunction:Fire()
end
local function SpaciousEvent()
called5 = true
SpaciousCallWhileFunction:Fire()
end
local function VIPEvent()
called6 = true
VIPCallWhileFunction:Fire()
end
ADE.Event:Connect(function(FireDisplay)
if Base:FindFirstChild("PlayerOwnerShip") then
for _, player in pairs(game.Players:GetChildren()) do
if player.Name == Base.PlayerOwnerShip.Value then
if FireDisplay == true then -- If the Display is from a Fire Part
local BoostHolder = player.PlayerGui.BoostDisplayScreenGui.BoostHolder
for _, DisplayFrame in pairs(BoostHolder.DisplayParent:GetChildren()) do
if DisplayFrame:FindFirstChild("DisplayValue") then
if DisplayFrame.DisplayValue.Value == "DisplayIsFire" then
FireAlreadyDisplaying = true
end
end
end
if FireAlreadyDisplaying ~= true then
FireDisplaySample = BoostHolder.DisplaySample:Clone()
local DisplayValue = Instance.new("StringValue")
DisplayValue.Parent = FireDisplaySample
DisplayValue.Name = "DisplayValue"
FireDisplaySample.Parent = BoostHolder.DisplayParent
FireDisplaySample.Name = "Display"
FireDisplaySample.Visible = true
FireDisplaySample.Size = UDim2.new(0.013, 0, 0.25, 0)
FireDisplaySample.Position = UDim2.new(0.052*(#BoostHolder.DisplayParent:GetChildren()-1), 0, 0, 0)
FireDisplaySample.Description.TitleText.Text = "Fire Boost"
FireDisplaySample.Description.InfoText1.Text = "x1.5 Movement Speed"
FireDisplaySample.Description.InfoText6.Text = FireWaitTime.."s"
FireDurationFrame = BoostHolder.DisplaySample:Clone()
FireDurationFrame.Parent = FireDisplaySample
FireDurationFrame.Name = "DurationBar"
FireDurationFrame.Visible = true
FireDurationFrame.Size = UDim2.new(1, 0, 1, 0)
local Icon = BoostHolder.Icons.FireIcon:Clone()
DisplayValue.Value = "DisplayIsFire"
Icon.Parent = FireDisplaySample
Icon.Visible = true
FireDisplaySample.ImageColor3 = Color3.fromRGB(145, 0, 0)
FireDurationFrame.ImageColor3 = Color3.fromRGB(255, 0, 0)
FireDisplaySample.Description.BorderColor3 = FireDurationFrame.ImageColor3
local tween = TweenService:Create(FireDurationFrame, tweenInfo, {Size = UDim2.new(0, 0, 1, 0)})
local tween2 = TweenService:Create(FireDisplaySample, tweenInfo2, {Size = UDim2.new(0.052, 0,1, 0)})
tween2:Play()
tween:Play()
FireDisplaySample.MouseEnter:Connect(function()
FireDisplaySample.Description.Visible = true
end)
FireDisplaySample.MouseLeave:Connect(function()
FireDisplaySample.Description.Visible = false
end)
end
if FireCooldown == false then
FireCooldown = true
FireEvent()
elseif FireCooldown == true then
FireWaitTime=5
FireDurationFrame.Size = UDim2.new(1, 0, 1, 0)
tween:Destroy()
tween = TweenService:Create(FireDurationFrame, tweenInfo, {Size = UDim2.new(0, 0, 1, 0)})
tween:Play()
task.wait(1)
end
end
end
end
end
end)
CallWhileFunction.Event:Connect(function()
while FireWaitTime > 0 and FireCooldown == true do
task.wait(1)
FireWaitTime -= 1
FireDisplaySample.Description.InfoText6.Text = FireWaitTime.."s"
end
if FireWaitTime <= 0 then
FireDisplaySample:Destroy()
FireCooldown = false
FireAlreadyDisplaying = false
FireWaitTime = 5
end
end)
ADE2.Event:Connect(function(BoosterDisplayCash)
if Base:FindFirstChild("PlayerOwnerShip") then
for _, player in pairs(game.Players:GetChildren()) do
if player.Name == Base.PlayerOwnerShip.Value then
if BoosterDisplayCash == true then -- If the Display is from a Booster Part + Ability is x2 Cash
local BoostHolder = player.PlayerGui.BoostDisplayScreenGui.BoostHolder
for _, DisplayFrame in pairs(BoostHolder.DisplayParent:GetChildren()) do
if DisplayFrame:FindFirstChild("DisplayValue") then
if DisplayFrame.DisplayValue.Value == "DisplayIsBoosterX2Cash" then
BoostCashAlreadyDisplaying = true
end
end
end
if BoostCashAlreadyDisplaying ~= true then
BoostDisplayCashSample = BoostHolder.DisplaySample:Clone()
local DisplayValue = Instance.new("StringValue")
DisplayValue.Parent = BoostDisplayCashSample
DisplayValue.Name = "DisplayValue"
BoostDisplayCashSample.Parent = BoostHolder.DisplayParent
BoostDisplayCashSample.Name = "Display"
BoostDisplayCashSample.Visible = true
BoostDisplayCashSample.Size = UDim2.new(0.013, 0, 0.25, 0)
BoostDisplayCashSample.Position = UDim2.new(0.052*(#BoostHolder.DisplayParent:GetChildren()-1), 0, 0, 0)
BoostDisplayCashSample.Description.TitleText.Text = "Cash Boost"
BoostDisplayCashSample.Description.InfoText1.Text = "x2 Cash"
BoostDisplayCashSample.Description.InfoText6.Text = BoostCashWaitTime.."s"
BoostCashDurationFrame = BoostHolder.DisplaySample:Clone()
BoostCashDurationFrame.Parent = BoostDisplayCashSample
BoostCashDurationFrame.Name = "DurationBar"
BoostCashDurationFrame.Visible = true
BoostCashDurationFrame.Size = UDim2.new(1, 0, 1, 0)
local Icon = BoostHolder.Icons.BoosterX2CashIcon:Clone()
DisplayValue.Value = "DisplayIsBoosterX2Cash"
Icon.Parent = BoostDisplayCashSample
Icon.Visible = true
BoostDisplayCashSample.ImageColor3 = Color3.fromRGB(19, 145, 0)
BoostCashDurationFrame.ImageColor3 = Color3.fromRGB(35, 255, 50)
BoostDisplayCashSample.Description.BorderColor3 = BoostCashDurationFrame.ImageColor3
tween3 = TweenService:Create(BoostCashDurationFrame, tweenInfo3, {Size = UDim2.new(0, 0, 1, 0)})
local tween2 = TweenService:Create(BoostDisplayCashSample, tweenInfo2, {Size = UDim2.new(0.052, 0,1, 0)})
tween2:Play()
tween3:Play()
BoostDisplayCashSample.MouseEnter:Connect(function()
BoostDisplayCashSample.Description.Visible = true
end)
BoostDisplayCashSample.MouseLeave:Connect(function()
BoostDisplayCashSample.Description.Visible = false
end)
end
if BoostCashCooldown == false then
BoostCashCooldown = true
BoostCashEvent()
elseif BoostCashCooldown == true then
BoostCashWaitTime=10
BoostCashDurationFrame.Size = UDim2.new(1, 0, 1, 0)
tween3:Destroy()
tween3 = TweenService:Create(BoostCashDurationFrame, tweenInfo3, {Size = UDim2.new(0, 0, 1, 0)})
tween3:Play()
task.wait(1)
end
end
end
end
end
end)
BoosterCashWhileFunction.Event:Connect(function()
while BoostCashWaitTime > 0 and BoostCashCooldown == true do
task.wait(1)
BoostCashWaitTime -= 1
BoostDisplayCashSample.Description.InfoText6.Text = BoostCashWaitTime.."s"
end
if BoostCashWaitTime <= 0 then
BoostDisplayCashSample:Destroy()
BoostCashCooldown = false
BoostCashAlreadyDisplaying = false
BoostCashWaitTime = 10
end
end)
ADE3.Event:Connect(function(BoosterDisplayAllShiny)
if Base:FindFirstChild("PlayerOwnerShip") then
for _, player in pairs(game.Players:GetChildren()) do
if player.Name == Base.PlayerOwnerShip.Value then
if BoosterDisplayAllShiny == true then -- If the Display is from a Booster Part + Ability is All Shiny
local BoostHolder = player.PlayerGui.BoostDisplayScreenGui.BoostHolder
for _, DisplayFrame in pairs(BoostHolder.DisplayParent:GetChildren()) do
if DisplayFrame:FindFirstChild("DisplayValue") then
if DisplayFrame.DisplayValue.Value == "DisplayIsBoosterAllShiny" then
BoostAllShinyAlreadyDisplaying = true
end
end
end
if BoostAllShinyAlreadyDisplaying ~= true then
BoostDisplayAllShinySample = BoostHolder.DisplaySample:Clone()
local DisplayValue = Instance.new("StringValue")
DisplayValue.Parent = BoostDisplayAllShinySample
DisplayValue.Name = "DisplayValue"
BoostDisplayAllShinySample.Parent = BoostHolder.DisplayParent
BoostDisplayAllShinySample.Name = "Display"
BoostDisplayAllShinySample.Visible = true
BoostDisplayAllShinySample.Size = UDim2.new(0.013, 0, 0.25, 0)
BoostDisplayAllShinySample.Position = UDim2.new(0.052*(#BoostHolder.DisplayParent:GetChildren()-1), 0, 0, 0)
BoostDisplayAllShinySample.Description.TitleText.Text = "Shiny Boost"
BoostDisplayAllShinySample.Description.InfoText1.Text = "Shiny Chance = 100% (for new cubes)"
BoostDisplayAllShinySample.Description.InfoText6.Text = BoostAllShinyWaitTime.."s"
BoostAllShinyDurationFrame = BoostHolder.DisplaySample:Clone()
BoostAllShinyDurationFrame.Parent = BoostDisplayAllShinySample
BoostAllShinyDurationFrame.Name = "DurationBar"
BoostAllShinyDurationFrame.Visible = true
BoostAllShinyDurationFrame.Size = UDim2.new(1, 0, 1, 0)
local Icon = BoostHolder.Icons.BoosterAllShinyIcon:Clone()
DisplayValue.Value = "DisplayIsBoosterAllShiny"
Icon.Parent = BoostDisplayAllShinySample
Icon.Visible = true
BoostDisplayAllShinySample.ImageColor3 = Color3.fromRGB(19, 145, 0)
BoostAllShinyDurationFrame.ImageColor3 = Color3.fromRGB(35, 255, 50)
BoostDisplayAllShinySample.Description.BorderColor3 = BoostAllShinyDurationFrame.ImageColor3
tween = TweenService:Create(BoostAllShinyDurationFrame, tweenInfo, {Size = UDim2.new(0, 0, 1, 0)})
local tween2 = TweenService:Create(BoostDisplayAllShinySample, tweenInfo2, {Size = UDim2.new(0.052, 0,1, 0)})
tween2:Play()
tween:Play()
BoostDisplayAllShinySample.MouseEnter:Connect(function()
BoostDisplayAllShinySample.Description.Visible = true
end)
BoostDisplayAllShinySample.MouseLeave:Connect(function()
BoostDisplayAllShinySample.Description.Visible = false
end)
end
if BoostAllShinyCooldown == false then
BoostAllShinyCooldown = true
BoostAllShinyEvent()
elseif BoostAllShinyCooldown == true then
BoostAllShinyWaitTime=5
BoostAllShinyDurationFrame.Size = UDim2.new(1, 0, 1, 0)
tween:Destroy()
tween = TweenService:Create(BoostAllShinyDurationFrame, tweenInfo, {Size = UDim2.new(0, 0, 1, 0)})
tween:Play()
task.wait(1)
end
end
end
end
end
end)
BoosterAllShinyWhileFunction.Event:Connect(function()
while BoostAllShinyWaitTime > 0 and BoostAllShinyCooldown == true do
task.wait(1)
BoostAllShinyWaitTime -= 1
BoostDisplayAllShinySample.Description.InfoText6.Text = BoostAllShinyWaitTime.."s"
end
if BoostAllShinyWaitTime <= 0 then
BoostDisplayAllShinySample:Destroy()
BoostAllShinyCooldown = false
BoostAllShinyAlreadyDisplaying = false
BoostAllShinyWaitTime = 5
end
end)
ADE4.Event:Connect(function(BoosterDisplayGoldChance)
if Base:FindFirstChild("PlayerOwnerShip") then
for _, player in pairs(game.Players:GetChildren()) do
if player.Name == Base.PlayerOwnerShip.Value then
if BoosterDisplayGoldChance == true then -- If the Display is from a Booster Part + Ability is All Shiny
local BoostHolder = player.PlayerGui.BoostDisplayScreenGui.BoostHolder
for _, DisplayFrame in pairs(BoostHolder.DisplayParent:GetChildren()) do
if DisplayFrame:FindFirstChild("DisplayValue") then
if DisplayFrame.DisplayValue.Value == "DisplayIsBoosterGoldChance" then
BoostGoldChanceAlreadyDisplaying = true
end
end
end
if BoostGoldChanceAlreadyDisplaying ~= true then
BoostDisplayGoldChanceSample = BoostHolder.DisplaySample:Clone()
local DisplayValue = Instance.new("StringValue")
DisplayValue.Parent = BoostDisplayGoldChanceSample
DisplayValue.Name = "DisplayValue"
BoostDisplayGoldChanceSample.Parent = BoostHolder.DisplayParent
BoostDisplayGoldChanceSample.Name = "Display"
BoostDisplayGoldChanceSample.Visible = true
BoostDisplayGoldChanceSample.Size = UDim2.new(0.013, 0, 0.25, 0)
BoostDisplayGoldChanceSample.Position = UDim2.new(0.052*(#BoostHolder.DisplayParent:GetChildren()-1), 0, 0, 0)
BoostDisplayGoldChanceSample.Description.TitleText.Text = "Gold Boost"
BoostDisplayGoldChanceSample.Description.InfoText1.Text = "x2 Gold Chance"
BoostDisplayGoldChanceSample.Description.InfoText6.Text = BoostGoldChanceWaitTime.."s"
BoostGoldChanceDurationFrame = BoostHolder.DisplaySample:Clone()
BoostGoldChanceDurationFrame.Parent = BoostDisplayGoldChanceSample
BoostGoldChanceDurationFrame.Name = "DurationBar"
BoostGoldChanceDurationFrame.Visible = true
BoostGoldChanceDurationFrame.Size = UDim2.new(1, 0, 1, 0)
local Icon = BoostHolder.Icons.BoosterGoldChanceIcon:Clone()
DisplayValue.Value = "DisplayIsBoosterGoldChance"
Icon.Parent = BoostDisplayGoldChanceSample
Icon.Visible = true
BoostDisplayGoldChanceSample.ImageColor3 = Color3.fromRGB(19, 145, 0)
BoostGoldChanceDurationFrame.ImageColor3 = Color3.fromRGB(35, 255, 50)
BoostDisplayGoldChanceSample.Description.BorderColor3 = BoostGoldChanceDurationFrame.ImageColor3
tween3 = TweenService:Create(BoostGoldChanceDurationFrame, tweenInfo3, {Size = UDim2.new(0, 0, 1, 0)})
local tween2 = TweenService:Create(BoostDisplayGoldChanceSample, tweenInfo2, {Size = UDim2.new(0.052, 0,1, 0)})
tween2:Play()
tween3:Play()
BoostDisplayGoldChanceSample.MouseEnter:Connect(function()
BoostDisplayGoldChanceSample.Description.Visible = true
end)
BoostDisplayGoldChanceSample.MouseLeave:Connect(function()
BoostDisplayGoldChanceSample.Description.Visible = false
end)
end
if BoostGoldChanceCooldown == false then
BoostGoldChanceCooldown = true
BoostGoldChanceEvent()
elseif BoostGoldChanceCooldown == true then
BoostGoldChanceWaitTime=10
BoostGoldChanceDurationFrame.Size = UDim2.new(1, 0, 1, 0)
tween3:Destroy()
tween3 = TweenService:Create(BoostGoldChanceDurationFrame, tweenInfo3, {Size = UDim2.new(0, 0, 1, 0)})
tween3:Play()
task.wait(1)
end
end
end
end
end
end)
BoosterGoldChanceWhileFunction.Event:Connect(function()
while BoostGoldChanceWaitTime > 0 and BoostGoldChanceCooldown == true do
task.wait(1)
BoostGoldChanceWaitTime -= 1
BoostDisplayGoldChanceSample.Description.InfoText6.Text = BoostGoldChanceWaitTime.."s"
end
if BoostGoldChanceWaitTime <= 0 then
BoostDisplayGoldChanceSample:Destroy()
BoostGoldChanceCooldown = false
BoostGoldChanceAlreadyDisplaying = false
BoostGoldChanceWaitTime = 10
end
end)
ADE5.Event:Connect(function(SpaciousDisplay)
if Base:FindFirstChild("PlayerOwnerShip") then
for _, player in pairs(game.Players:GetChildren()) do
if player.Name == Base.PlayerOwnerShip.Value then
if SpaciousDisplay == true then -- If the Display is from a Spacious Part
local BoostHolder = player.PlayerGui.BoostDisplayScreenGui.BoostHolder
for _, DisplayFrame in pairs(BoostHolder.DisplayParent:GetChildren()) do
if DisplayFrame:FindFirstChild("DisplayValue") then
if DisplayFrame.DisplayValue.Value == "DisplayIsSpacious" then
SpaciousAlreadyDisplaying = true
end
end
end
if SpaciousAlreadyDisplaying ~= true then
SpaciousDisplaySample = BoostHolder.DisplaySample:Clone()
local DisplayValue = Instance.new("StringValue")
DisplayValue.Parent = SpaciousDisplaySample
DisplayValue.Name = "DisplayValue"
SpaciousDisplaySample.Parent = BoostHolder.DisplayParent
SpaciousDisplaySample.Name = "Display"
SpaciousDisplaySample.Visible = true
SpaciousDisplaySample.Size = UDim2.new(0.013, 0, 0.25, 0)
SpaciousDisplaySample.Position = UDim2.new(0.052*(#BoostHolder.DisplayParent:GetChildren()-1), 0, 0, 0)
SpaciousDisplaySample.Description.TitleText.Text = "Force Field"
SpaciousDisplaySample.Description.InfoText1.Text = "Increase Pickup Range"
SpaciousDisplaySample.Description.InfoText6.Text = SpaciousWaitTime.."s"
SpaciousDurationFrame = BoostHolder.DisplaySample:Clone()
SpaciousDurationFrame.Parent = SpaciousDisplaySample
SpaciousDurationFrame.Name = "DurationBar"
SpaciousDurationFrame.Visible = true
SpaciousDurationFrame.Size = UDim2.new(1, 0, 1, 0)
local Icon = BoostHolder.Icons.SpaciousIcon:Clone()
DisplayValue.Value = "DisplayIsSpacious"
Icon.Parent = SpaciousDisplaySample
Icon.Visible = true
SpaciousDisplaySample.ImageColor3 = Color3.fromRGB(108, 41, 146)
SpaciousDurationFrame.ImageColor3 = Color3.fromRGB(160, 66, 205)
SpaciousDisplaySample.Description.BorderColor3 = SpaciousDurationFrame.ImageColor3
tween3 = TweenService:Create(SpaciousDurationFrame, tweenInfo3, {Size = UDim2.new(0, 0, 1, 0)})
local tween2 = TweenService:Create(SpaciousDisplaySample, tweenInfo2, {Size = UDim2.new(0.052, 0,1, 0)})
tween2:Play()
tween3:Play()
SpaciousDisplaySample.MouseEnter:Connect(function()
SpaciousDisplaySample.Description.Visible = true
end)
SpaciousDisplaySample.MouseLeave:Connect(function()
SpaciousDisplaySample.Description.Visible = false
end)
end
if SpaciousCooldown == false then
SpaciousCooldown = true
SpaciousEvent()
elseif SpaciousCooldown == true then
SpaciousWaitTime=10
SpaciousDurationFrame.Size = UDim2.new(1, 0, 1, 0)
tween3:Destroy()
tween3 = TweenService:Create(SpaciousDurationFrame, tweenInfo3, {Size = UDim2.new(0, 0, 1, 0)})
tween3:Play()
task.wait(1)
end
end
end
end
end
end)
SpaciousCallWhileFunction.Event:Connect(function()
while SpaciousWaitTime > 0 and SpaciousCooldown == true do
task.wait(1)
SpaciousWaitTime -= 1
SpaciousDisplaySample.Description.InfoText6.Text = SpaciousWaitTime.."s"
end
if SpaciousWaitTime <= 0 then
SpaciousDisplaySample:Destroy()
SpaciousCooldown = false
SpaciousAlreadyDisplaying = false
SpaciousWaitTime = 10
end
end)
ADE6.Event:Connect(function(DisplayVIP)
if Base:FindFirstChild("PlayerOwnerShip") then
for _, player in pairs(game.Players:GetChildren()) do
if player.Name == Base.PlayerOwnerShip.Value then
if DisplayVIP == true then -- If the Display is from a Spacious Part
local BoostHolder = player.PlayerGui.BoostDisplayScreenGui.BoostHolder
for _, DisplayFrame in pairs(BoostHolder.DisplayParent:GetChildren()) do
if DisplayFrame:FindFirstChild("DisplayValue") then
if DisplayFrame.DisplayValue.Value == "DisplayIsVIP" then
VIPAlreadyDisplaying = true
end
end
end
if VIPAlreadyDisplaying ~= true then
VIPDisplaySample = BoostHolder.DisplaySample:Clone()
local DisplayValue = Instance.new("StringValue")
DisplayValue.Parent = VIPDisplaySample
DisplayValue.Name = "DisplayValue"
VIPDisplaySample.Parent = BoostHolder.DisplayParent
VIPDisplaySample.Name = "Display"
VIPDisplaySample.Visible = true
VIPDisplaySample.Size = UDim2.new(0.013, 0, 0.25, 0)
VIPDisplaySample.Position = UDim2.new(0.052*(#BoostHolder.DisplayParent:GetChildren()-1), 0, 0, 0)
VIPDisplaySample.Description.TitleText.Text = "VIP Boost"
VIPDisplaySample.Description.InfoText1.Text = "+10% Cash"
VIPDisplaySample.Description.InfoText2.Text = "+25% Gold chance"
VIPDisplaySample.Description.InfoText3.Text = "+25% Toxic chance"
VIPDisplaySample.Description.InfoText4.Text = "+25% Bloody chance"
VIPDisplaySample.Description.InfoText6.Text = VIPWaitTime.."s"
VIPDurationFrame = BoostHolder.DisplaySample:Clone()
VIPDurationFrame.Parent = VIPDisplaySample
VIPDurationFrame.Name = "DurationBar"
VIPDurationFrame.Visible = true
VIPDurationFrame.Size = UDim2.new(1, 0, 1, 0)
local Icon = BoostHolder.Icons.CrownIcon:Clone()
DisplayValue.Value = "DisplayIsVIP"
Icon.Parent = VIPDisplaySample
Icon.Visible = true
VIPDisplaySample.ImageColor3 = Color3.fromRGB(184, 179, 28)
VIPDurationFrame.ImageColor3 = Color3.fromRGB(244, 255, 42)
VIPDisplaySample.Description.BorderColor3 = VIPDurationFrame.ImageColor3
tween3 = TweenService:Create(VIPDurationFrame, tweenInfo3, {Size = UDim2.new(0, 0, 1, 0)})
local tween2 = TweenService:Create(VIPDisplaySample, tweenInfo2, {Size = UDim2.new(0.052, 0,1, 0)})
tween2:Play()
tween3:Play()
VIPDisplaySample.MouseEnter:Connect(function()
VIPDisplaySample.Description.Visible = true
end)
VIPDisplaySample.MouseLeave:Connect(function()
VIPDisplaySample.Description.Visible = false
end)
end
if VIPCooldown == false then
VIPCooldown = true
VIPEvent()
elseif VIPCooldown == true then
VIPWaitTime=10
VIPDurationFrame.Size = UDim2.new(1, 0, 1, 0)
tween3:Destroy()
tween3 = TweenService:Create(VIPDurationFrame, tweenInfo3, {Size = UDim2.new(0, 0, 1, 0)})
tween3:Play()
task.wait(1)
end
end
end
end
end
end)
VIPCallWhileFunction.Event:Connect(function()
while VIPWaitTime > 0 and VIPCooldown == true do
task.wait(1)
VIPWaitTime -= 1
VIPDisplaySample:WaitForChild("Description").InfoText6.Text = VIPWaitTime.."s"
end
if VIPWaitTime <= 0 then
VIPDisplaySample:Destroy()
VIPCooldown = false
VIPAlreadyDisplaying = false
VIPWaitTime = 10
end
end)
while RunService.Stepped:Wait() do
if Base:FindFirstChild("PlayerOwnerShip") then
for _, player in pairs(game.Players:GetChildren()) do
if player.Name == Base.PlayerOwnerShip.Value then
local BoostHolder = player.PlayerGui.BoostDisplayScreenGui.BoostHolder
local DisplayParent = BoostHolder:WaitForChild("DisplayParent"):GetChildren()
for Display = 1, #DisplayParent do
local DisplayNumber = DisplayParent[Display]
DisplayNumber.Position = UDim2.new(0.052*(Display-1), DisplayNumber.Position.X.Offset, DisplayNumber.Position.Y.Scale, DisplayNumber.Position.Y.Offset)
end
end
end
end
end
Any tips and tricks are appreciated!