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

how would i create a welcome screen to appear ONLY FOR THE PLAYER THAT ENTERS?

Asked by
lytew 99
4 years ago

how would i create a welcome screen to appear ONLY FOR THE PLAYER THAT ENTERS AND NOT FOR OTHERS THAT HAVE ALREADY ENTERED? I created a welcome screen, but I think it only appears once when someone enters and then does not appear for the other players. The script is located in the starterGui.TextLabel (is that why? I should leave the script in serverscriptService? if so, why? I wanted a welcome message to appear, just that script:

local butao = game.Workspace.teleportbuttom
function clicartexto ()
local texto = 'O jogo começará em '

for i = 1,#texto do
script.Parent.Text = string.sub(texto,1,i)

wait(0.1)

local cor = coroutine.wrap(function()
    local sound = Instance.new("Sound")
    sound.Volume = 1.6
    sound.SoundId = 'rbxassetid://151715959'
    sound.Parent = script.Parent.Parent
    sound:Play()
    sound.Ended:Wait()
    sound:Destroy()
end)
cor()
end

end
butao.ClickDetector.MouseClick:connect(clicartexto)

2 answers

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

You need to make a LocalScript, and only appears in the player's PlayerGui. PlayerGui is a GUI that only shows on the players, but not others.

Enter a script in the workspace, and paste this inside:

function added(player)  -- if a player was joined/added

    local GUI = script.IntroGui:clone()
    GUI.Parent = player:WaitForChild("PlayerGui")

end
game.Players.PlayerAdded:connect(added)

Now, when you are copied this inside, make the welcome screen parent to the script.

BUT, it does not appear if you click it. The welcome screen will automatically clone for the people who just joined.

If you have more suggestion, like make it appears when people click on a specific button, ask me, I'll try my best to do it, thanks!

Edit:

I'll explain how this script works.

function added(player) -- function

    local GUI = script.IntroGui:clone() -- this clones the IntroGui
    GUI.Parent = player:WaitForChild("PlayerGui") -- Clones the Gui to the PlayerGui

end
game.Players.PlayerAdded:connect(added) -- fire the function when a player was added

Remember, this needs a LocalScript, a LocalScript might able to use the PlayerGui, script doesn't.

0
oh of course… sorry to ask but could you explain the script you created? i didn't understand the part about 'introgui: clone' and why you put player in the parentheses of the function (function added ('player') .Could you please explain to me? lytew 99 — 4y
0
Ok, I'll do some edits there. Xapelize 2658 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

To explain your confusion to the accepted answer. You can call functions in different ways. The accepted answer uses function [function name] and calls the function name at the end. You, however, use :connect(function() in other words you can word out the accepted answer like this:

game.Players.PlayerAdded:connect(function(player) --When a player is added it gets the player
    local GUI = script.IntroGui:Clone() -- This clones the Intro gui but it has no parent
    GUI.Parent =  player:WaitForChild('PlayerGui') -- This gives the cloned gui a parent, the player gui.
end)

I hope this explanation helps you out!

0
ah,então quer dizer que 'player' nos parenteses de function significa é o nome da função? Boa explicação cara,valeu só tive outr lytew 99 — 4y
0
my bad,bro, I forgot to ask the question in English .. ah, so does that mean that 'player' in the parentheses of function means is the name of the function? Good explanation man, thanks I only had anotherheses of function means is the name of the function? Good explanation man, thanks I only had another lytew 99 — 4y

Answer this question