Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to use playerAdded for ScreenGui fade?

So basically I have a script that greets player with black screen when he joins but soon after becomes transparent. It works in StarterGui but it really problematic in editor because it is visible. I want to use the PlayerAdded so that the ScreenGui is put in Players.LocalPlayer.PlayerGui but I have problems with it. Excuse me for my horrible sentencing.

script:

local Players = game:GetService("Players")
local gui = Players.LocalPlayer.PlayerGui
local blink = game:GetService("ServerStorage"):GetChildren("blink")

Players.PlayerAdded:Connect(function()
	blink:Clone(gui)
end)

error that comes with game start:

ServerScriptService.blinker:2: attempt to index nil with 'PlayerGui'  -  Server - blinker:2
Stack Begin  -  Studio
Script 'ServerScriptService.blinker', Line 2  -  Studio - blinker:2
Stack End  -  Studio

1 comment

0

Is the script you are using a LocalScript or a normal Script?

1 answer

I saw your mistakes. You put :Clone(gui) AND you used :GetChildren("blink")

local Players = game:GetService("Players")
local gui = Players.LocalPlayer.PlayerGui
local blink = game:GetService("ReplicatedStorage"):WaitForChild("blink") -- Use `Instance:WaitForChild(childName) instead (clients dont have access to ServerStorage so I would recommend moving the gui to ReplicatedStorage which both the server and client have access to.)

Players.PlayerAdded:Connect(function()
    local Clone - blink:Clone() -- A clone creates a new copy of an instance, this can be defined as a variable or done 2 ways
Clone.Parent = gui
--blink:Clone().Parent = gui -- most simplest way
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.