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

One time Intro GUI doesn't work. after "game.Players.PlayerAdded:connect(functio..." was added, why?

game.Players.PlayerAdded:connect(function(player)
	
local black = script.Parent.Parent
local title = script.Parent
local joingame = script.Parent.Parent.TextButton
	
	for i = 0,1,0.1 do
	black.BackgroundTransparency = i
	wait(0.1)
	
	if black.BackgroundTransparency == 1 then
	script.Parent:TweenPosition (UDim2.new(0.5, -100, 0.1, -25), "Out", "Quad", 1, true)
	joingame.Visible = true   
	end
end

function onClicked()
	for i = 1,0,-0.1 do
		black.BackgroundTransparency = i
		wait (0.1)
	end
	wait(2)
game:GetService('Players').LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
game:GetService('Players').LocalPlayer.CameraMode = Enum.CameraMode.Classic
game:GetService('Players').LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
title.Visible = false
joingame.Visible = false
	wait(1)
	for i = 0,1,0.1 do
		black.BackgroundTransparency = i
		wait(0.1)
	end
end

script.Parent.Parent.TextButton.MouseButton1Down:connect(onClicked)

end)

I cannot see the intro, After adding "game.Players.PlayerAdded:connect(function(player)", I need help

2 comments

0

Is this a localscript?

0

Yes it is.

1 answer

Assuming this is a local script, you do not need to use the PlayerAdded event. It should work perfectly fine.

local black = script.Parent.Parent
local title = script.Parent
local joingame = script.Parent.Parent.TextButton

    for i = 0,1,0.1 do
    black.BackgroundTransparency = i
    wait(0.1)

    if black.BackgroundTransparency == 1 then
    script.Parent:TweenPosition (UDim2.new(0.5, -100, 0.1, -25), "Out", "Quad", 1, true)
    joingame.Visible = true   
    end
end

function onClicked()
    for i = 1,0,-0.1 do
        black.BackgroundTransparency = i
        wait (0.1)
    end
    wait(2)
game:GetService('Players').LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
game:GetService('Players').LocalPlayer.CameraMode = Enum.CameraMode.Classic
game:GetService('Players').LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
title.Visible = false
joingame.Visible = false
    wait(1)
    for i = 0,1,0.1 do
        black.BackgroundTransparency = i
        wait(0.1)
    end
end

script.Parent.Parent.TextButton.MouseButton1Down:connect(onClicked)

3 comments

0

Great :D, but i want it to only go into them the FIRST time they spawn in. what about if i add "game.Players.PlayerAdded:connect(function(player) script.LocalScript:clone().Parent = player.CharacterAdded:wait() end)" will it work?

0

Yes, you could just put the gui inside a PlayerAdded script inside of serverscriptservice, and on player added, clone the gui into theyr playergui. Make sure the localscript is disabled, and the clone gets enabled again.

0

Thanks so much :D

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