I am writing a script that changes through frames for a Character Customizer GUI and I wanted to know if it was clear and as simple but efficient as possible.
I am working with a couple of other people (not scripters) on a game and hope that if they need to change something without me they will understand and be able to.
If you could give me feedback and suggestions on what to add/change that would be helpful (I am still in the learning process for scripting).
If anyone wants to take this script for their own use feel free but please do not upload it to the Toolbox.
The script:
local Frame = script.Parent
local CurrentFrame = nil
local Buttons = Frame.Parent.ButtonBar
local HatFrame = Frame.HatPicker
local ClothesFrame = Frame.ClothingPicker
local SkinFrame = Frame.SkinColor
local HatButton = Buttons.Hat
local HairButton = Buttons.Hair
local ClothesButton = Buttons.Clothing
local SkinButton = Buttons.Skin
-- Hats
HatButton.MouseButton1Click:Connect(function()
local CurrentFrame = HatFrame
local OtherFrames = ClothesFrame and SkinFrame
if CurrentFrame.Visible == false then
CurrentFrame.Visible = true
if OtherFrames.Visible == true then
OtherFrames.Visible = false
end
end
end)
-- Clothing
ClothesButton.MouseButton1Click:Connect(function()
local CurrentFrame = ClothesFrame
local OtherFrames = SkinFrame and HatFrame
if CurrentFrame.Visible == false then
CurrentFrame.Visible = true
if OtherFrames.Visible == true then
OtherFrames.Visible = false
end
end
end)
-- Skin
SkinButton.MouseButton1Click:Connect(function()
local CurrentFrame = SkinFrame
local OtherFrames = ClothesFrame and HatFrame
if CurrentFrame.Visible == false then
CurrentFrame.Visible = true
if OtherFrames.Visible == true then
OtherFrames.Visible = false
end
end
end)