Recently, I have been trying to make a intro GUI with cutscene’s/effects etc. I added a credits GUI that works when I open it but for some odd reason, doesn’t close properly. By close properly I mean, the buttons don’t reposition themselves back to there original position. When I click the close button, the Credits Frame works fine but the Play button and the Credits button don’t work for some reason. I tried to debug it for any errors, or mistakes in the code but sadly did not find any. Any and all help will be appreciated, so thank you in advance! Code will be pasted below.
Local Script:
local tweenservice = game:GetService("TweenService")
local size = 11
local blur = Instance.new("BlurEffect")
local db = false
--//Setup\\--
script.Parent.CreditsFrame.Position = UDim2.new(-10, 0,0.093, 0)
script.Parent.CreditsFrame.close.Visible = false
script.Parent.CreditsFrame.Visible = false
local playgui = script.Parent
if db == true then
script.Parent:Destroy()
blur:Destroy()
end
camera = game.Workspace.Camera
local cutscenetime = 6
local tweeninfo = TweenInfo.new(cutscenetime,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)
local tweeninfo2 = TweenInfo.new(2,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)
function tween(part1,part2)
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = part1.CFrame
local tween = tweenservice:Create(camera,tweeninfo,{CFrame = part2.CFrame})
tween:Play()
wait(cutscenetime + 0.1)
playgui.Enabled = true
end
function tween2(part1,part2)
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = part1.CFrame
local tween = tweenservice:Create(camera,tweeninfo2,{CFrame = part2.CFrame})
tween:Play()
end
wait(0.15)
blur.Enabled = true
blur.Size = size
blur.Parent = game.Workspace.Camera
tween(game.Workspace.Cut1,game.Workspace.Cut2)
script.Parent.Play.MouseButton1Down:Connect(function()
tween2(game.Workspace.Cut2,game.Workspace.Cut3)
script.Parent.Play:TweenPosition(UDim2.new(5,0,0.505, 0),"Out","Quint",10)
wait(0.1)
script.Parent.Credits:TweenPosition(UDim2.new(5,0,0.641,0),"Out","Quint",10)
wait(0.1)
script.Parent:Destroy()
wait(2 + 0.1)
camera.CameraType = Enum.CameraType.Custom
blur:Destroy()
db = true
end)
script.Parent.Credits.MouseButton1Down:Connect(function()
local creditsbutton = script.Parent.Credits
local playbutton = script.Parent.Play
local creditsframe = script.Parent.CreditsFrame
local close = script.Parent.CreditsFrame.close
creditsframe.Visible = true
creditsbutton:TweenPosition(UDim2.new(5,0,0.505,0),"Out","Quint",10)
wait(0.1)
playbutton:TweenPosition(UDim2.new(5,0,0.641,0),"Out","Quint",10)
wait(0.1)
creditsbutton.Visible = false
playbutton.Visible = false
wait(0.1)
creditsframe:TweenPosition(UDim2.new(0.291,0,0.093,0),"Out","Quint",1.5)
wait(0.1)
close.Visible = true
end)
script.Parent.CreditsFrame.close.MouseButton1Down:Connect(function()
--[[local creditsbutton = script.Parent.Credits
local playbutton = script.Parent.Play
local creditsframe = script.Parent.CreditsFrame
local close = script.Parent.CreditsFrame.close--]]
script.Parent.Play.Visible = true
script.Parent.Credits.Visible = true
script.Parent.CreditsFrame:TweenPosition(UDim2.new(-10, 0,0.093, 0),"Out","Quint",5)
wait(0.3)
script.Parent.Play:TweenPosition(UDim2.new(0.379,0,0.505,0),"Out","Quint",1)
print("Done-1")
wait(0.1)
script.Parent.Credits:TweenPosition(UDim2.new(0.379,0,0.641,0),"Out","Quint",1)
print("Done")
wait(0.1)
script.Parent.CreditsFrame.Visible = false
end)