I wish to make an intro for my game that when players enter it, they will click the GUI and it will slide away off to the side and spawn their character into the game. I have not worked with GUI's very much so I really am clueless about how to do it effectively.
COMMUNITY QUESTION
How do you make a clickable GUI at the beginning of your game?
2 answers
First you need to create a GUI, with the buttons and such inside (and the scripts for it). Then, place the GUI somewhere safe, where it won't accidentally get deleted.
Then, in workspace, or ServerScriptService, create a script that places the GUI inside new player's PlayerGuis, kinda like this one...
local GUI = Game:GetService("ServerScriptService").GUI -- You need to change this to where the script goes.
local Players = Game:GetService("Players")
Players.PlayerAdded:connect(function(Player)
--// Destroys first Character
local Character = Player.CharacterAdded:wait()
Character:Destroy()
-- Gets his/her's PlayerGui
local PlayerGui = Player:WaitForChild("PlayerGui")
-- Clones new GUI to the PlayerGui
local newGUI = GUI:Clone()
newGUI.Parent = PlayerGui
end)
Then in a button in the GUI, make it Respawn the Player, with LoadCharacter. You might need to change it a little, but this is kinda what you;d be looking for.
I find the :WaitForChild() function not working properly for me. If it gets stuck waiting for PlayerGui then use this:
Script in Workspace:
game.Players.PlayerAdded:connect(function(Player) --Listen for players entering game
Player.CharacterAdded:wait()
wait(0.1) --Allow the game to load the character a little before we destroy it...
Player.Character:Destroy()
repeat
if Player:FindFirstChild("PlayerGui") then
break --I know this is not necessary but whenever I use it, it just gets stuck
end
wait()
until Player:FindFirstChild("PlayerGui")
Player.PlayerGui:ClearAllChildren() --Clear out any other Guis that might get in the way. When we click the spawn button it should put all the guis in StarterGui in there
game.ServerStorage.EnterGui:Clone().Parent = Player.PlayerGui --Place your EnterGui into ServerStorage
end)
LocalScript in the button that spawns your player in the EnterGui
local Player = game.Players.LocalPlayer
local Frame = script.Parent.Parent --The Frame that the button is in
script.Parent.MouseButton1Click:connect(function()
script.Parent.Text = "Spawning..."
wait(0.1)
Frame:TweenPosition(UDim2.new(0, 0, 1, 0), "Out", "Back", 1) --Create a cool dynamic effect. Make sure the Frame's Size is 1, 0, 1, 0 and the position is 0, 0, 0, 0!
wait(1.1)
Player:LoadCharacter(true) --Loads the character.
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Just make it so that when a player joins, a GUI will be put into their PlayerGui that when clicked, will tweenPosition out of their screen.