Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited by User#24403 5 years ago

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)
0
use for loop for the transparency of the "Fader" ~ for i = 0.1,0.7,0.05 do wait (.3) fader.BackgroundTransparency = i ~ xmaanzach 28 — 5y
0
Code Block Please DuckyRobIox 280 — 5y
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. Miniller 562 — 5y
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. oilsauce 196 — 5y
View all comments (2 more)
0
tweenserver is better EXpodo1234ALT 18 — 5y
0
Thanks guys! Dev_Coda 31 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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.

0
also the camera might have not loaded yet, so you might want to put a wait() EXpodo1234ALT 18 — 5y
Ad

Answer this question