Bloxburg inspired picker

This system is a Bloxburg inspired picker that looks like this:
image
It works flawlessly, except I needed to add a delay to make it work with no flaws after about 5 minutes of testing.

Here is the code.

local Player: Player = game:GetService("Players").LocalPlayer
local TweenService: TweenService = game:GetService("TweenService")
local CashierArea = game:GetService("Workspace").PartPoints.Cashier
local TweenInfoBillboard: TweenInfo = TweenInfo.new(0.4, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false)
local ZonePlus = require(game:GetService("ReplicatedStorage").Zone)
local Billboard = script.Parent

local UIVisible: BindableEvent = Instance.new("BindableEvent")

for _, CashierPoints in pairs(CashierArea:GetChildren()) do
	local Zone = ZonePlus.new(CashierPoints:WaitForChild("CashierZone"))
	Zone.localPlayerEntered:Connect(function()
		UIVisible:Fire(CashierPoints.CashierBillboard, true)
	end)
	Zone.localPlayerExited:Connect(function()
		UIVisible:Fire(CashierPoints.CashierBillboard, false)
	end)
end

local InTween: Tween = nil
local OutTween: Tween = nil

UIVisible.Event:Connect(function(Area, In)
	if In then
		task.wait(0.4)
		InTween = TweenService:Create(Billboard, TweenInfoBillboard, {Size = UDim2.new(0, 400, 0, 250)})
		script.Parent.Adornee = Area
		InTween:Play()
		InTween.Completed:Wait()
		InTween = nil
	else
		OutTween = TweenService:Create(Billboard, TweenInfoBillboard, {Size = UDim2.new(0, 0, 0, 0)})
		if InTween then
			InTween.Completed:Wait()
		end
		OutTween:Play()
		OutTween.Completed:Wait()
		OutTween = nil
	end
end)

The main thing I am worried about is the In part. After the in part, I added task.wait(0.4) Not a huge problem, but players will need to wait 0.4 seconds in order to use the system. I originally had a OutTween.Completed:Wait(), but that made it not work as well.

If you can help make this code better, that will be appreciated!

Thank you!

2 Likes

Looks really nice, all I say is people probably want to change up the GUI a little bit as it is not the neatest. But over all, very nice job and good Code Review!

3 Likes