LocalScript won't change any gui elements

Hello!
This may be a very simple fix for others, however what i’m trying to do is when the player joins a game, the screen will show up black. Here is a little snippet of what won’t work:

local bf = script.Parent.BlackFrame
local StarterGui = game:GetService("StarterGui")
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
  bf.BackgroundTransparency = 0
end)

I have checked all the guis and they all go where they should be, it is just this that won’t work.

3 Likes

The PlayerAdded Event only works in Server Scripts it wont work in Local Scripts.

2 Likes

I’m pretty sure it does, doesn’t it?

If this is a local script inside a screen Gui within starter gui im pretty sure you wouldn’t really need to use playeradded, instead you could probably just enable or disable the entire gui altogether.

So when you’re in studios you just disable the “Enabled” option for the screen gui and for the local script just enable the gui since the local script will already run when the player joins the game.

script.Parent.Enabled = true

I rewrote the whole code and now it works. Thanks