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

How to make player Invisible/Invulnerable/Frozen during Load Screen?

Asked by 6 years ago

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! :)

0
Due to the really bad problems in line 4 I assume you are not advanced enough for the proper character solution. (involving remote events) cabbler 1942 — 6y
1
https://scriptinghelpers.org/questions/16871/how-to-prevent-a-player-from-spawning using this is better imo than hiding the character. User#5423 17 — 6y
0
Cabbler - Thank you for the response. I'll be the first to admit i know enough to know what i don't know, however i do have many remote events in my game and will be more than happy to read the proper solution if you would like to respond with it. :) I'm sure others have had similar questions who will stumble on this post in the future. Never2Humble 90 — 6y
0
Kingdom5 - Thank you for this response! It looks very promising for my problem! Being able to prevent the loading of the character before the game starts is ideal. Thank you for this! :) Never2Humble 90 — 6y

Answer this question