Need help with a fade-in script, cause won't work

  1. Trying to make a fade in script.

  2. There is no issue, but when I reset the screen becomes black, other than actually becoming black when running the script.

  3. None yet, it just doesn’t work

Here’s the script and please tell me what’s wrong, cause I don’t know and I’ve been trying to research.

for i = 1,100 do
	game.StarterGui.Button.Fade.BackgroundTransparency -= 0.01
	wait (0.01)
end

Check if you wrote something wrong in the script or any extra spaces you left

The StarterGui is actually in relation to the server’s side (And other players that’ll be replicated to their side), & if you’re attempting to play this from the client then you won’t be able to look at the changes

You can define it as using script.Parent.Parent (Etc) and a LocalScript instead for a more smooth transition, I’d also recommend using TweenService to accomplish this

local TS = game:GetService("TweenService")
local FadeObject --Define it here

local FadeTween = TS:Create(FadeObject, TweenInfo.new(1), {BackgroundTransparency = 1})
FadeTween:Play()

So basically changing the entire thing?

If you can, you could just put the LocalScript in with the Frame & do it that way to make it easier if you want

Just make sure to define your FadeObject

I can’t really just put it in, it’s meant to be kind of an event, when clicking a button.

If that’s the case then, you could just use the MouseButton1Down/MouseButton1Click Events if it’s a GuiButton that you want to click

Certain objects do have these kind of events to make it easier to detect when a specific object is interacted with, not sure if this is what you’d want though:

local Button --Define the Button to click on here
local FadeObject --Define the Object you want to Fade here
local TS = game:GetService("TweenService")

local function Clicked()
    local FadeTween = TS:Create(FadeObject, TweenInfo.new(1), {BackgroundTransparency = 1})
    FadeTween:Play()
end

Button.MouseButton1Down:Connect(Clicked)

Alright, so two buttons I believe then, also all of this is inspired off of my friend, cause of some stuff he has been making.

I tried making a button now inside of another screengui with a frame that’ll fade in, didn’t realy work.


Also this is basically what I want to learn.

Your for loop is set to run for about one second (100 x 0.01 = 1 second) so it’s probably just going too fast for you to notice the change. But do what other posters have said and use a Tween.

It’s not going to fast, because I have a button ready to activate a event with some music and such, and it should fade out at the end.

Can I see the current script you’re using, and possibly a picture of where your Frame that’s gonna fade is in your Explorer? I’d appreciate it if you can do that

So it doesn’t work at all? Or?

It doesn’t work at all, even if it seems correct.

Ofc, don’t mind the mess, I am new to scripting btw.
(Btw it’s the first script, like full one)

1 Like

Double check the path, it might just be pointing to the wrong thing. Check for duplicates as that would mess it up.

I’m 100% I don’t have any duplicates, and I’ve been trying multiple methods, I think it’s the script, and not anything else, just what I did, because when I reset it turns dark ofc, and shows the screengui.

Hm, judging by what I see, it looks like 1 of these lines seems to possibly stop the script from running in the first place

If you could also, can you please send the hierarchy of where that Script is exactly in the Explorer?

Here you go, it is in StarterGUI.
image

Use a LocalScript instead of a Script since it deals with the PlayerGui