Hi Everyone, I just want to know I am trying to make a GUI visible when a player joins the game.
But, it won’t work. I tried everything and it still won’t work.
If im doing something wrong plz tell me.
Hi Everyone, I just want to know I am trying to make a GUI visible when a player joins the game.
But, it won’t work. I tried everything and it still won’t work.
If im doing something wrong plz tell me.
From what I know the local script will run after the event can be cached.
You don’t have to use a PlayerAdded
event since local scripts run when the player joins anyway
You’d have to do this:
local Players = game.Players
local Player = Players.LocalPlayer
Players.PlayerAdded:Connect(function(Player)
Player.PlayerGui.ScreenGui.StarterFrame.Frame.Visible = true
wait(5)
Player.PlayerGui.ScreenGui.StarterFrame.Frame.Visible = false
end)
You can just have the code without PlayerAdded event.
@legs_v correctly identified the answer that you don’t really need a PlayerAdded
since localscripts run when the client joins. But I want to point some other things with your code
script.Parent.Visible
in this casegame:GetService("Players")
so as it’s the more recommended version as game.Players
can have a chance of erroring if the name of the Players
service is differentYou only really need the visible changing code, so just this
local frame = script.Parent
frame.Visible = true
wait(5)
frame.Visible = false
No need for the other stuff as this will run when the client joins the game
@Kon_Cyerthedeer Use what I had done, simplest way of doing what you need as it still wont work cause you’re referencing StarterGui instead of the Guis in the player
So you want me to do it like this.
local player = game.Players.LocalPlayer
local PGui = player.PlayerGui
local Gui = PGui:WaitForChild("ScreenGui")
Gui.ScreenGui.StarterFrame.Visible = true
wait(5)
Gui.ScreenGui.StarterFrame.Visible = false
That overcomplicates it slightly though, the localscript is in the thing he wants to change around, he can just do script.Parent
to get the StarterFrame, like how I did in my example
Yeah that works too, I skipped the thought of that.
I tried it and it still didn’t work
Could it be that the game isn’t loaded by the time you’re entering? Maybe try this?
if not game:IsLoaded() then
game.Loaded:Wait()
end
local frame = script.Parent
frame.Visible = true
wait(5)
frame.Visible = false
oh, i got it do you know how to put the GUI in the player GUI.
Guis in StarterGui automatically replicate to each Player’s PlayerGui, so if you put it there, it’ll be placed there without having to do put it there yourself
ok I got it thank you
.
I know a solution has been made, but the Visible setting is unnecessary, just set the frame as visible by properties as default, then wait 5 seconds and set the visible property to false.