Hey y’all, I am having an issue with my script. It does work, but the problem is that it apparently after the first click, it works. But when I click it again, it goes back to the first function instead of the next one below.
-
What do you want to achieve?
I am trying to make the images slowly fade in and out, the fade in works, but not the fade out. -
What is the issue?
It doesn’t go to the next code below. -
What solutions have you tried so far?
I don’t know another solution as of right now
Here is the script:
function onClick()
local state = false
local Screen1 = script.Parent.Parent.Parent.Parent.Parent.Parent.Screen1.Individual.ScreenDisplay.Camel
local Screen2 = script.Parent.Parent.Parent.Parent.Parent.Parent.Screen2.Individual.ScreenDisplay.Camel2
local Screen3 = script.Parent.Parent.Parent.Parent.Parent.Parent.Screen3.Individual.ScreenDisplay.Camel3
local Screen4 = script.Parent.Parent.Parent.Parent.Parent.Parent.Screen4.Individual.ScreenDisplay.Camel4
local ts = game:GetService("TweenService")
info = TweenInfo.new(0.5)
local goal1 = {}
goal1.ImageTransparency = 0
local goal2 = {}
goal2.ImageTransparency = 1
spawn(function()
state = not state
if state then
Screen1.ImageTransparency = 0.98
Screen2.ImageTransparency = 0.98
Screen3.ImageTransparency = 0.98
Screen4.ImageTransparency = 0.98
wait(0.5)
script.Parent.BorderColor3 = Color3.new(255,0,0)
ts:Create(Screen1,info,goal1):Play()
ts:Create(Screen2,info,goal1):Play()
ts:Create(Screen3,info,goal1):Play()
ts:Create(Screen4,info,goal1):Play()
else
wait(0.5)
script.Parent.BorderColor3 = Color3.new(0,170,0)
ts:Create(Screen1,info,goal2):Play()
ts:Create(Screen2,info,goal2):Play()
ts:Create(Screen3,info,goal2):Play()
ts:Create(Screen4,info,goal2):Play()
end
end)
end
script.Parent.MouseButton1Click:Connect(onClick)```