#Hi! New Developer learning the practice here, need help making code neater/cleaning it up

1 messages · Page 1 of 1 (latest)

final cloud
#

So for reference this is probably my first bit of code I've done myself, and I'm proud of the results but I feel like the code itself needs some work, is there a better way for me to use TweenService without creating a bunch of different variables for every UI element?

Or is there anything I should change that would be good practice for the future? Is there anything I did that's in bad practice and I should change?

The LocalScript and result of the code below:

https://medal.tv/games/roblox/clips/lZJAtxKojtiOWS9Xt?invite=cr-MSx6R2IsNTI2NDU4NDA2&v=14

local chains = button:WaitForChild("ChainsStart")
local title = button.Parent.Title
local stroke = button.Parent.Title:WaitForChild("UIStroke")
local background = button.Parent.Parent:WaitForChild("Primary")
local outer = background.Outer
local rotationSpeed = 20
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
outer.Visible = false




local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)


local strokeGoal = {
    Transparency = 1
}

local buttonGoal = {
    BackgroundTransparency = 1,
    TextTransparency = 1
}


local chainsGoal = {
    ImageTransparency = 1
}

local titleGoal = {
    TextTransparency = 1
}
    
local buttonFade = TweenService:Create(button, tweenInfo, buttonGoal)
local chainsFade = TweenService:Create(chains, tweenInfo, chainsGoal)
local titleFade = TweenService:Create(title, tweenInfo, titleGoal)
local strokeFade = TweenService:Create(stroke, tweenInfo, strokeGoal)

RunService.RenderStepped:Connect(function(deltaTime)
    chains.Rotation = chains.Rotation + (rotationSpeed * deltaTime)
end)

button.MouseButton1Click:Connect(function()
    rotationSpeed = 1440
    buttonFade:Play()
    chainsFade:Play()
    titleFade:Play()
    strokeFade:Play()
    task.wait(1)
    button.Parent.Enabled = false
    outer.Visible = true
end)

Watch Untitled by rloe and millions of other Roblox videos on Medal. #roblox

▶ Play video
#

I know the code is probably attrocious lol

hollow linden
#

you can order your script by sections, for example:

-- Services
...get services

-- Gui
...get gui

you can comment them as you want

and also the variables for all the tweens objective you can just call :CreateTween with the tables inside the function

#

and for the rotation animation you can do an endless loop with tween too

fiery beacon
hollow linden
#

I mean he's saying tips to make code neater/cleaning, and sections make it way neater and cleaner. And about the other thing is another way, yeah, in this case I don't see too much tweens so I would just do it manually, but table is a way too

fiery beacon
#

Services, gui is obvious

hollow linden
#

well, in my case I prefer to have commented to differentiate sections but as I say that's personal opinion

fiery beacon
#

So your code becomes more readable

hollow linden
#

that's kinda what I said, not really need to comment but as least separate with your prefer