You’re probably yielding forever on line 5. Is there any warnings in the console when you play the game?
That’s unusual. Is the script a descendant of StarterCharacterScripts or StarterPlayerScripts? Is it enabled? Basically the backpack, the character, the playergui, and playerscripts.
It’s in StarterPlayerScripts, also this is the correct variable for ‘btn’
local btn = game.StarterGui.ScreenGui.PlayBtn
I had the old variable
wait a minute, I think you should get the btn when it’s actually inside of PlayerGui
in the player, rather than before it’s replicated. as in player.PlayerGui:WaitForChild(“ScreenGui”).PlayBtn
Oh ok I fixed that.
The function still isn’t getting triggered for some reason
Is there something wrong with the way I wrote this?
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function()
No, there isn’t.
did you make sure the char isn’t yielding forever? try printing something before you define the character variable
I don’t think so
print("test")
local char = plr.Character or plr.CharacterAdded:Wait()
print("test2")
are you the only one in the game? Because playeradded events can’t fire for the player that’s joining…
Oh yes I am the only one in the server. I didn’t realize that; what event should I switch it to so it’s for the player joining?
You don’t. Make a local server. Have one player join, and then have another one join. Or try team test.
But the server I want to use it for will be 1 player based because it’s apart of an intro UI for that player who just joined. Is there a way to make it trigger for the player joining?
Don’t use an event, just do it. No function, no event. But if you want to make an intro, you need to use ReplicatedFirst, to ensure that the script runs before everything else.
Here’s the process for doing it.
- Create a new local script in
ReplicatedFirst
- Under that script, put your screengui.
- in the script, simply use a playeradded event, whenever a player is added, clone the gui and put it inside their playergui folder. after that, you can tween it, do all of that fancy smanchy stuff, then remove it.
Somewhere in that script though, do this:player.PlayerGui:SetTopbarTransparency(1)
.
So that playeradded event is not going to work if you’re the first person to join and start a server?
No, It work work regardless if you’re the player joining. Why would you want to know when a player is added, when you’re the playeradded. I think you’ve misunderstood the meaning of playeradded. It’s not when “I joined”. It’s for everyone else when “Someone else joined the server”.
I see, I did misunderstand the meaning.
I assume in this case I wouldn’t need an event since it’s a local script and it’s a function for when the local player joins the game. So just creating a function and calling it with no event will be the best bet in this case?
Yes, but I you should do it with replicatedfirst, since it won’t really be an INTRO if it isn’t first, see the instructions I added above.
Okay that worked. I appreciate all your help I was very confused haha
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.