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

How do I fix my PlayerAdded function to run my script?

Asked by 3 years ago

I am working on an obby and I want to have a loading screen. I added a local script inside of the screen GUI of the loading screen and typed the code below. When I join the game however, the script does not function and there are no errors so I do not know what to fix. I realized when I removed the PlayerAdded function, my script ran perfectly. Is there any way that I can fix my PlayerAdded function so when the player joins, the loading screen will appear? Help is much appreciated and thank you in advanced.

local LS = script.Parent.LoadingScreenFrame
local MuteMusic = script.Parent.Parent.MuteMusic.MuteMusicFrame
local ShopButton = script.Parent.Parent.ShopGUI.ShopButton
local TeleportButton = script.Parent.Parent.TeleportGUI.TeleportButton
game.Players.PlayerAdded:Connect(function()
    MuteMusic.Visible = false
    ShopButton.Visible = false
    TeleportButton.Visible = false

    LS.Visible = true

end)

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Just delete the function, as whenever the player joins, the script will execute to set "visible = false" and "visible = true".

local LS = script.Parent.LoadingScreenFrame
local MuteMusic = script.Parent.Parent.MuteMusic.MuteMusicFrame
local ShopButton = script.Parent.Parent.ShopGUI.ShopButton
local TeleportButton = script.Parent.Parent.TeleportGUI.TeleportButton

    MuteMusic.Visible = false
    ShopButton.Visible = false
    TeleportButton.Visible = false

    LS.Visible = true

If this didn't work please reply, and I'll try a different fix. I'm a beginner myself.

If it did work, please accept this answer as solved! We will both get a reward!

Edit: Let me know!

Ad

Answer this question