Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My background transparency fade in game intro wont work any help?

So the custom cam works but the UI show up does not and the fade in intro does not work either. Any help?

--//Variables
local play = script.Parent.Play
local chapter = script.Parent.Chapter
local title = script.Parent.Title
local fader = script.Parent.Fade
local campart = workspace.Cameras:WaitForChild("JoinedCam")

while wait(.05) do
	workspace.Camera.CameraType = "Scriptable"
	workspace.Camera.CFrame = campart.CFrame
end

--//Fade
fader.Visible = true
fader.BackgroundTransparency = .1
wait(.5)
fader.BackgroundTransparency = .15
wait(.5)
fader.BackgroundTransparency = .2
wait(.5)
fader.BackgroundTransparency = .3
wait(.5)
fader.BackgroundTransparency = .45
wait(.5)
fader.BackgroundTransparency = .7
wait(.5) 
fader:Destroy()

wait(1)
title.Visible = true
wait(1)
chapter.Visible = true
wait(1)
play.Visible = true

play.MouseButton1Click:Connect(function()
title.Visible = false
chapter.Visible = false
play.Visible = false
workspace.Camera.CameraType = "Custom"
workspace.Cameras.JoinedCam:Destroy()
game.Players.LocalPlayer.HumanoidRootPart.CFrame = CFrame.new(-553.1, -35.9, -24)--Spawnpoint
end)

6 comments

0

use for loop for the transparency of the "Fader" ~ for i = 0.1,0.7,0.05 do wait (.3) fader.BackgroundTransparency = i ~

0

Code Block Please

0

Why you expect him to write the code in a code block? He wrote it in a comment, because that code may not fully solve the issue.

0

If you want to fade in smoothly and don't want to do lazy math, I'd suggest using :lerp() and RunService.RenderStepped:Wait() for your wait() function.

0

tweenserver is better

0

Thanks guys!

1 answer

✓ Accepted answer

#Problem

the problem is that you're creating a indefinite while loop over the code, which makes it yield the thread for a indefinite amount of time unless you break it or the condition in it turns false which you cant do that since you set the condition of the loop as the wait() method. also you can just use workspace.CurrentCamera instead, which is the client's camera and theres no need for a while loop anyways. use a for loop instead of setting the transparency each time or you could use TweenService for a smoother effect and more options.

--//Variables
local play = script.Parent.Play
local chapter = script.Parent.Chapter
local title = script.Parent.Title
local fader = script.Parent.Fade
local campart = workspace.Cameras:WaitForChild("JoinedCam")
local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()

camera.CameraType = Enum.CameraType.Scriptable -- use enums
camera.CFrame = campart.CFrame

--//Fade
fader.Visible = true
for i = 1,0,.1 do
	fader.BackgroundTransparency = i
	wait()
end
fader:Destroy()

wait(1)
title.Visible = true
wait(1)
chapter.Visible = true
wait(1)
play.Visible = true

play.MouseButton1Click:Connect(function()
	title.Visible = false
	chapter.Visible = false
	play.Visible = false
	camera.CameraType = Enum.CameraType.Custom
	workspace.Cameras.JoinedCam:Destroy()
	char.HumanoidRootPart.CFrame = CFrame.new(-553.1, -35.9, -24) --Spawnpoint
end)

and HumanoidRootPart isnt a object of the player object (game.Players.LocalPlayer) but the player's character.

1 comment

0

also the camera might have not loaded yet, so you might want to put a wait()

This discussion is preserved as it was. New answers, comments, and votes are closed.