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

GUI not disappearing?

I want a GUI to disappear just when the player enters. I even gave the script a 2 second wait, so it can load, but the Button doesn't disappear. In Studio, it works fine, but in the Player it bugs

Here's the entire script

local Player = game.Players.LocalPlayer
local LoadScreen = script.Parent.Parent.Parent.Parent.LoadScreen.Frame
local Center = script.Parent.Parent
local BlackScreen = Center.Parent.BlackScreen
local Button = script.Parent

wait(2)

Button.Transparency = 1
BlackScreen.Transparency = 1
Center.Visible = false
local Spawned = Player:FindFirstChild("Spawned")

repeat
	wait(.1)
until
	LoadScreen.Visible == false
	
wait(.1)

Center.Visible = true

for i = 1, 40 do
	Button.Transparency = Button.Transparency - 0.025
	wait(.01)
end

wait(.1)
local Debounce = false

script.Parent.MouseButton1Down:connect(function()
	if Debounce == false then
		Debounce = true
		wait(.1)
		for i = 1, 40 do
			Button.Transparency = Button.Transparency + 0.025
			wait(.01)
		end
		for i = 1, 40 do
			BlackScreen.Transparency = BlackScreen.Transparency - 0.025
			wait(.01)
		end
		wait(.5)
		local Target = CFrame.new(0, 5, 0)
		if Player.Character and Player.Character.Torso then
			Player.Character.Torso.CFrame = Target
		end
		Spawned.Value = true
		for i = 1, 40 do
			BlackScreen.Transparency = BlackScreen.Transparency + 0.025
			wait(.01)
		end
	end
end)

1 comment

0

UGH... Too long. You didn't explain it well enough.

2 answers

✓ Accepted answer

I've had a problem like this before. I think your issue is you are not referencing the button in Player gui, in the player object, under game.Players

Try something like this:

game.Players.PlayerAdded:connect(function(player)
	-- other variables here
	local Button = player.PlayerGui.ScreenGui.Button --Location of button in player
	--continue with the script
end)

anything in startergui gets cloned into the player's playergui when the player enters the game. By clicking play solo and looking under game.Players.Player.PlayerGui you should be able to find the button there. That is the button you are referencing and changing, not the one in startergui.

you can also access the player by using a local script and doing game.Players.LocalPlayer

Send me a message if you still need help!

4 comments

0

Not PlayerEntered, PlayerAdded, sorry

0

Just edit the answer.

0

fixed :)

0

Thank You!

Add wait(.5) at the very first line, if it's local script then it loads faster then any other object so it when it runs nothing else is loaded. But it works when you are in studio because it's already locally based.

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