BackgroundTransparency tween won't play

So I wanted to make that the screen turns black. But The BackgroundTransparency tween won’t play, while not having any errors.
Here’s the full script

script.Parent.Play.MouseButton1Click:Connect(function()
	for _, v in pairs(script.Parent:GetDescendants()) do
		if v:IsA("TextButton") or v:IsA("TextLabel") or v:IsA("ImageButton") or v:IsA("Frame") then
			v.Visible = false
		end
	end
	task.wait(2)
	script.Parent.Exploded.Value = true
	local main = workspace.NukeExplosion.MainExplosion
	local wave = workspace.NukeExplosion.ExplosionWave
	TS:Create(wave, TweenInfo.new(5), {Size = Vector3.new(1500, 1500, 1500)}):Play()
	TS:Create(main, TweenInfo.new(8), {Size = Vector3.new(500, 500, 500)}):Play()
	script.Parent.Explosion:Play()
	task.wait(0.5)
	TS:Create(script.Parent.GreyScreen, TweenInfo.new(2), {BackgroundTransparency=0}):Play() --This is the tween
	task.wait(2)
	script.Parent.Exploded.Value = false
end)

Looks like GreyScreen isn’t a frame. It’ll need to be in order to actually work.

the tween may not be playing because it is being overridden by the Visible property being set to false in the same event. You can try setting the Visible property to false after the tween has completed using the Completed event.
Is this the correct code

script.Parent.Play.MouseButton1Click:Connect(function()
for _, v in pairs(script.Parent:GetDescendants()) do
if v:IsA(“TextButton”) or v:IsA(“TextLabel”) or v:IsA(“ImageButton”) or v:IsA(“Frame”) then
v.Visible = false
end
end
task.wait(2)
script.Parent.Exploded.Value = true
local main = workspace.NukeExplosion.MainExplosion
local wave = workspace.NukeExplosion.ExplosionWave
TS:Create(wave, TweenInfo.new(5), {Size = Vector3.new(1500, 1500, 1500)}):Play()
TS:Create(main, TweenInfo.new(8), {Size = Vector3.new(500, 500, 500)}):Play()
script.Parent.Explosion:Play()
task.wait(0.5)
local greyScreenTween = TS:Create(script.Parent.GreyScreen, TweenInfo.new(2), {BackgroundTransparency=0}):Play()
greyScreenTween.Completed:Connect(function()
script.Parent.Exploded.Value = false
script.Parent.GreyScreen.Visible = false
end)
end)

Oh. Found the issue. The frame was just not in the screen

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.