Hello!
Question: While a player is loading the game, they automatically generate inside the lobby before their load screen finishes. How can I make the player transparent, invulnerable, and unable to move until they click the "Play" button?
Here is the LocalScript I have going inside ReplicatedFirst:
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui") PlayerGui:SetTopbarTransparency(0) local p = game.Players.LocalPlayer:FindFirstChild("Humanoid") p.Transparency = 1 p.WalkSpeed = 0 p.Jump = false p.Humanoid.JumpPower = 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 script.Parent:RemoveDefaultLoadingScreen() 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
This is the error I receive:
ReplicatedFirst.LoadingScript3:6: attempt to index local 'p' (a nil value)
I know I'm screwing up where I establish the player there on Line 4, but I'm blanking on how to coordinate this properly. I know I need to do these things for the player's experience. Alternatively, if there's a way to prevent the player from being added until after they hit the Play button, I'm all ears! I've tried looking into CharacterAutoLoads on the wiki, but haven't made any headway.
Thanks! :)