Hello!
Question: I want to prevent the character from being added to the game, until the press the "Play" button inside my ReplicatedFirst script. How do I make this work?
I know it has something to do with CharacterAdded, and maybe a RemoteEvent, but all my attempts thus far have failed. So in my scripts below, I've only included the parts that do work correctly.
This is my Local Script inside ReplicatedFirst that starts the moment the player beings:
local Players = game:GetService("Players") local Player = game.Players.LocalPlayer script.Parent:RemoveDefaultLoadingScreen() local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui") PlayerGui:SetTopbarTransparency(0) local screen = script:WaitForChild("LoadingScreen") local bar = screen.Frame.LoadingBar.Bar local text = screen.Frame.LoadingBar.LoadingText local button = screen.Frame.PlayButton button.Visible = false screen.Parent = PlayerGui local count = 0 while count <= 100 do text.Text = count .. "%" bar:TweenSize(UDim2.new(count / 100, 0, 1, 0), "Out", "Quad", .01) count = count + 1 wait() end button.Visible = true button.MouseButton1Down:connect(function() screen:Destroy() local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui") PlayerGui:SetTopbarTransparency(1) Player:LoadCharacter() end)
I don't want to delay/prevent re-spawning, just prevent the auto-spawn the first time the player enters the game. Any advice would be much appreciated. :) Thanks!
Hope this helps! Straight from the good old wiki!
local respawnDelay = 5 game.Players.CharacterAutoLoads = false game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) -- find the humanoid, and detect when it dies local humanoid = character:FindFirstChild("Humanoid") if humanoid then humanoid.Died:connect(function() wait(respawnDelay) player:LoadCharacter() end) end end) player:LoadCharacter() -- load the character for the first time end)
Script found on link
There's a setting in Players called CharacterAutoLoads. Once set to false, you use
<Player>:LoadCharacter() -<Player> is reference to the Player you want to spawn.