Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.