Hi, my fellow Devforumers, I was wondering a thing, that someone could kindly reply to, I have this piece of script, at a quick look, it looks correct , right?, but… the truth is, It’s acting weird!, let me break it for you
task.wait(.15)
local TweenService = game:GetService("TweenService")
local UI = script.Parent
local SettingsButton = UI:WaitForChild("Sbutton")
local SettingsBG = UI:WaitForChild("bg")
local StrokeSettingsBG = SettingsBG:WaitForChild("UIStroke")
local NightcoreButton = SettingsBG:WaitForChild("NightButton")
local NightcoreBG = UI:WaitForChild("nightcoreBg")
task.delay(1, function()
SettingsBG.ImageTransparency = 1
SettingsBG.Position = UDim2.new(0.284, 0,0.525, 33)
NightcoreButton.TextTransparency = 1
StrokeSettingsBG.Transparency = 1
end)
local tInfos = {
AppearSettingsBG_info = TweenInfo.new(
0.6,
Enum.EasingStyle.Sine
),
DisappearSettingsBG_info = TweenInfo.new(
0.5,
Enum.EasingStyle.Sine
),
}
local tweens = {
SettingsBGAppear = TweenService:Create(
SettingsBG,
tInfos["AppearSettingsBG_info"],
{ImageTransparency = 0.6 ,Position = UDim2.new(0.285, 0,0.499, 0)}
),
SettingsBGDisappear = TweenService:Create(
SettingsBG,
tInfos["AppearSettingsBG_info"],
{ImageTransparency = 1 ,Position = UDim2.new(0.284, 0,0.525, 33)}
),
UIStrokeAppear = TweenService:Create(
StrokeSettingsBG,
tInfos["AppearSettingsBG_info"],
{Transparency = 0}
),
UIStrokeDisappear = TweenService:Create(
StrokeSettingsBG,
tInfos["DisappearSettingsBG_info"],
{Transparency = 1}
),
NightcoreButtonAppear = TweenService:Create(
NightcoreButton,
tInfos["AppearSettingsBG_info"],
{TextTransparency = 0}
),
NightcoreButtonDisappear = TweenService:Create(
NightcoreButton,
tInfos["DisappearSettingsBG_info"],
{TextTransparency = 1}
),
}
local OnSettings = false
SettingsButton.MouseButton1Click:Connect(function()
if not OnSettings then
OnSettings = true
print("open")
tweens["UIStrokeDisappear"]:Cancel()
tweens["NightcoreButtonDisappear"]:Cancel()
tweens["SettingsBGDisappear"]:Cancel()
tweens["SettingsBGAppear"]:Play()
tweens["UIStrokeAppear"]:Play()
tweens["NightcoreButtonAppear"]:Play()
else
OnSettings = false
print("close")
tweens["UIStrokeAppear"]:Cancel()
tweens["NightcoreButtonAppear"]:Cancel()
tweens["SettingsBGAppear"]:Cancel()
tweens["SettingsBGDisappear"]:Play()
tweens["UIStrokeDisappear"]:Play()
tweens["NightcoreButtonDisappear"]:Play()
end
end)
When i click it slowly, it works perfect, but when i start clicking it too fast, it bugs!, or sometimes it disappears only the text and even stays static, the way i need it to work is , no matter how fast you are clicking it, it won’t bug and also play the correct tween when closing/opening