Hello developers.
Today I was trying to make a fade animation for my car dealership so it fades a frame in and out at the same time when you enter the dealership. So I made the script below, but fade doesn’t work, not even output no errors, it just doesn’t work. If anyone knows how to fix this please reply and thanks for reading.
local blur = Instance.new("BlurEffect",game.Workspace.CurrentCamera)
blur.Size = 0
local Frame = script.Parent
local XButton = script.Parent.X
local BlackUI = script.Parent.Parent.BlackUI
local ts = game:GetService("TweenService")
local blackUiin = ts:Create(BlackUI, TweenInfo.new(1.1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut), {BackgroundTransparency = 0})
local blackUiout = ts:Create(BlackUI, TweenInfo.new(1.1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut), {BackgroundTransparency = 1})
local Opened = false
game.ReplicatedStorage.GuiUp.OnClientEvent:Connect(function()
if not Opened then
Opened = true
blackUiin:Play()
wait()
blackUiout:Play()
Frame:TweenPosition(UDim2.new(0.5, 0,0.5, 0),"Out","Quint", 1, true)
for i = 0,10,1 do
wait()
blur.Size = 24
end
end
end)
XButton.MouseButton1Click:Connect(function()
if Opened then
Opened = false
blackUiin:Play()
wait()
blackUiout:Play()
Frame:TweenPosition(UDim2.new(0.5, 0,3, 0),"Out","Quint", 1, true)
for i = 10,0,-1 do
wait(0.09)
blur.Size = 0
end
end
end)
good day.
Maybe because the tweening animation didn’t get to play properly?
blackUiin:Play() -- 1.1 seconds until the animations end
wait() -- wait for about 0.03 seconds then continue playing the next tween animation.
blackUiout:Play() -- also 1.1 seconds until the animations end
Perhaps try putting the appropriate time in the wait() or else the result will be pretty weird.
blackUiin:Play() -- 1.1 seconds until the animations end
wait(1.2) -- Now wait until the tween finished it's job
blackUiout:Play() -- also 1.1 seconds until the animations end
One more question. I am trying to make the camera move also. And i am trying to move it with Cframe. I am new at scripting that’s why I way sound stupid to you but I added this:
if Frame:TweenPosition(UDim2.new(0.5, 0,0.5, 0)) then
camera.CameraType = Enum.CameraType.Scriptable
ts:Create(camera, TweenInfo.new(1), {CFrame = HMR.CFrame * CFrame.new(0, 1.5, -4) * CFrame.Angles(0, math.pi, 0)}):Play()
end
else
camera.CameraType = Enum.CameraType.Custom
end
at the end and in the output it says error: expected " and i don’t understand that. If you can help me I would be very happy.
Sorry for responding you late, it was pretty late here about 11:45 PM right now. erm so I’m not sure about the code but it probably has something to do with this line right here.
if Frame:TweenPosition(UDim2.new(0.5, 0,0.5, 0)) then
since you’re checking for its position I suggest you use this instead.
if Frame.Position == UDim2.new(0.5, 0, 0.5, 0) then
That works, but I don’t recommend that, you should use Tween.Completed instead, it’s more accurate and if you change the time the tween takes, you don’t have to manually change the wait, it does it automatically for you.
1 Like
That would also work but I mostly use wait() since (from what I’ve seen) TweenService is pretty accurate there is no delay once the tween is played, but Tween.Completed should also do the trick too yes.
there is no point in Tween.Completed if the camera is tweened with CFrame, and camera is going in only 1 direction
Well it’s essentially the same thing lol.
-- Without Tween.Completed
blackUiin:Play()
wait(1.2)
blackUiout:Play()
-- With Tween.Completed
blackUiin:Play()
blackUiin.Completed:Wait() -- waits 1.1 seconds
wait(0.1)
blackUiout:Play()
I am gonna try this. just to see. thanks
1 Like