The code does have affirm()
, the warn()
version of it, creates a path, gets names and icons for groups, experiences, and users and wayy more. I’m not satisfied that the code is messy because it uses too much elseif
s, requiring too many modules, and the functions are messy.
I went to the forums to find how to clean code but it doesn’t seem to do well with the code and breaks it
I need it to be more clean as I’m not the world’s smartest programmer, and it’s too messy
--// Services //--
local MPS = game:GetService("MarketplaceService")
local GroupService = game:GetService("GroupService")
local TweenService = game:GetService("TweenService")
local HttpService = game:GetService("HttpService")
local Players = game:GetService("Players")
local TextService = game:GetService("TextService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Lighting = game:GetService("Lighting")
local UserService = game:GetService("UserService")
--// Modules //--
local HttpProxyService = require(ReplicatedStorage.Services.HttpProxyService)
local BlueSerializer = require(ReplicatedStorage.BlueSerializer)
local Dump = require(ReplicatedStorage.Dump)
local DebrisGobbler = require(ReplicatedStorage.DebrisGobbler)
local TextModule = require(ReplicatedStorage.TextModule)
local BannerNotification = require(game.ReplicatedStorage.BannerNotificationModule)
--// Tables //--
local Connections = {}
local Serializers = BlueSerializer.serializers
local Deserializers = BlueSerializer.deserializers
--// Folders //--
local Sounds = script:WaitForChild("Sounds")
--// Module //--
local char = {}
function char:warnaffirm(assertion:any, err:string)
if not assertion then
warn(err)
end
end
function char:affirm(condition: any, errorMessage: any): ()
if not condition then
error(errorMessage, 3)
end
end
function char:GetUserInfo(id:number)
local info = UserService:GetUserInfosByUserIdsAsync({id})
end
function char:Tween(item:Instance, info:TweenInfo, list:{string:any})
local tween = TweenService:Create(item, info, list)
tween:Play()
return tween
end
function char:ConvertRaw(url:string) -- useful for converting GitHub and Pastebin Raw URLs
return loadstring(game:GetService("HttpService"):GetAsync(url))
end
function char:WrapText(richTextContent:{})
return TextModule:RichCustomize(richTextContent)
end
function char:CreateEnding(name:string, desc:string) --> This is a replacement for a legacy remote event
local blur = Instance.new("BlurEffect", Lighting)
blur.Size = 0
local player = game:GetService("Players"):GetPlayers()[1]
local PlayerGui = player:WaitForChild("PlayerGui")
local EndingGui = PlayerGui:WaitForChild("EndingGui")
local EndingFrame = EndingGui:WaitForChild("EndingFrame")
local frameTween = char:Tween(
EndingFrame,
TweenInfo.new(2, Enum.EasingStyle.Bounce, Enum.EasingDirection.InOut),
{Position = UDim2.fromScale(0,0)}
)
frameTween.Completed:Wait()
local blurTween = char:Tween(
blur,
TweenInfo.new(1.5, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut),
{Size = 30}
)
blurTween.Completed:Wait()
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
local Title = EndingFrame:WaitForChild("Title")
local Desc = EndingFrame:WaitForChild("Description")
local Retry = EndingFrame:WaitForChild("RetryButton")
Title.Text = `{name} Ending`
for i = 1, #Title.Text do --> This is an upgrade to the legacy AnimateUI
Title.MaxVisibleGraphemes = i
task.wait(0.035)
end
task.wait((0.035 * #name) + 0.035)
Desc.Text = desc
for i = 1, #desc do
Desc.MaxVisibleGraphemes = i
task.wait(0.035)
end
task.wait((0.035 * #desc) + 0.035)
Retry.Visible = true
local retryTween = char:Tween(
Retry,
TweenInfo.new(2, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut),
{BackgroundTransparency = 0, TextTransparency = 0}
)
return retryTween.Completed:Wait()
end
function char:LoadSound(name:string)
for _, sound:Sound in Sounds:GetChildren() do
if sound.Name == name then
local sc = sound:Clone()
sc.Name = Dump.Sound[7]
sc.Parent = workspace
sc:Play()
DebrisGobbler:AddItem(sc, sc.TimeLength)
end
end
end
function char:GetName(id:number, nameType:string)
if nameType == "experience" then
return MPS:GetProductInfo(id, Enum.InfoType.Asset).Name
elseif nameType == "group" then
return GroupService:GetGroupInfoAsync(id).Name
elseif nameType == "user" then
return Players:GetNameFromUserIdAsync(id)
end
end
function char:GetIcon(id:number, nameType:string)
if nameType == "experience" then
return MPS:GetProductInfo(id, Enum.InfoType.Asset).IconImageAssetId
elseif nameType == "group" then
return GroupService:GetGroupInfoAsync(id).EmblemUrl
elseif nameType == "user" then
return Players:GetUserThumbnailAsync(id, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
end
end
function char:GetNameAndIcon(id:number, nameType:string)
if nameType == "experience" then
return MPS:GetProductInfo(id, Enum.InfoType.Asset).IconImageAssetId, MPS:GetProductInfo(id, Enum.InfoType.Asset).Name
elseif nameType == "group" then
return GroupService:GetGroupInfoAsync(id).EmblemUrl, GroupService:GetGroupInfoAsync(id).Name
elseif nameType == "user" then
return Players:GetUserThumbnailAsync(id, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420), Players:GetNameFromUserIdAsync(id)
end
end
function char:ConvertDevEx(amount:number)
return amount * 0.0035
end
return char