Script doesn't work after I updated it and even when I remove it script doesn't works

Hi,
I added to my old play screen fade when player click “PLAY” and it doesn’t works even when i remove this update, here’s script:

local button = game.Players.LocalPlayer:WaitForChild("PlayerGui").StarterScreen.TextButton
local StarterScreen = game.Players.LocalPlayer:WaitForChild("PlayerGui").StarterScreen
local StarterGui = game:GetService("StarterGui")
local p = game:GetService("Players").LocalPlayer

StarterGui:SetCore("ResetButtonCallback", false)


p.Character:WaitForChild("Humanoid").JumpPower = 0
p.Character:WaitForChild("Humanoid").WalkSpeed = 0
button.Visible = true
StarterScreen.Enabled = true
p.PlayerGui.Chat.Enabled = false

button.Text = "5"
wait(1)
button.Text = "4"
wait(1)
button.Text = "3"
wait(1)
button.Text = "2"
wait(1)
button.Text = "1"
wait(1)
button.Text = "PLAY"

button.MouseButton1Click:Connect(function()
	repeat -- fade
		script.Parent.BackgroundTransparency -= 0.05 -- fade
		script.Parent.TextTransparency -= 0.05 -- fade
		wait(.05) -- fade
	until script.Parent.TextTransparency == 1 -- fade
	local SoundsFolder = game.StarterPlayer.SoundsFolder
	SoundsFolder.Theme.Looped = true
	SoundsFolder.Theme:Play()
	SoundsFolder.Theme.TimePosition = 0
	p.Character:WaitForChild("Humanoid").WalkSpeed = 16
	p.Character:WaitForChild("Humanoid").JumpPower = 50
	button.Visible = false
	StarterScreen.Enabled = false
	p.CameraMaxZoomDistance = 50
	p.PlayerGui.Chat.Enabled = true
end)

help

In the following part of your code:

button.MouseButton1Click:Connect(function()
	repeat -- fade
		script.Parent.BackgroundTransparency -= 0.05 -- fade
		script.Parent.TextTransparency -= 0.05 -- fade
		wait(.05) -- fade
	until script.Parent.TextTransparency == 1 -- fade

It seems that you’re basically lowering the value of TextTransparency of script.Parent by 0.05 every 0.05 second, lowering the value of the Transparency - it would never reach 1 this way. This is an infinity loop.

1 Like

Why are you using loops to fade out your GUI? You should use TweenService to accomplish the same effect, as well as keeping it smooth. Chances are it will fix your problem.

2 Likes

Here is a cleaner version of your script:

local plr = game:GetService("Players").LocalPlayer
local tweenService = game:GetService("TweenService")
local starterScreen = plr.PlayerGui:WaitForChild("StarterScreen")
local chat = plr.PlayerGui:WaitForChild("Chat")
local button = starterScreen.TextButton
local frame = script.Parent
local soundsFolder = game.StarterPlayer.SoundsFolder
local theme = soundsFolder.Theme

local controls = require(plr.PlayerScripts.PlayerModule):GetControls()
game:GetService("StarterGui"):SetCore("ResetButtonCallback", false)
controls:Disable()

button.Visible = true
starterScreen.Enabled = true
chat.Enabled = false 

for i = 5, 1, -1 do
  button.Text = i
  wait(1)
end
button.Text = "PLAY"

local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 1)
local goal = {BackgroundTransparency = 1, TextTransparency = 1}
local tween = tweenService:Create(frame, info, goal)

button.MouseButton1Click:Connect(function()
	button.Visible = false
	tween:Play()
	theme.Looped = true
	theme.TimePosition = 0
	theme:Play()
	controls:Enable()
	starterScreen.Enabled = false
	plr.CameraMaxZoomDistance = 50
	chat.Enabled = true 
end)
1 Like

Wow thanks, I will test this script (btw I’m bad at TweenService)

Have your output open in Roblox Studio as that’s where errors will show up in red (if any). You can open the output by going to the View section in the top bar and clicking on output. You probably already know this but just in case: the script you’re using must be a local script which must then be stored inside the UI object that you want to tween the transparency of.

1 Like