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

How do I fix this event?

script.Parent.Touched:connect(function() game.StarterGui.doorlocked.TextBox.Visible = true wait(2) game.StarterGui.doorlocked.TextBox.Visible = false end)

This script won't work. :/

1 comment

0

Code block.

1 answer

StarterGui does not change a player's Gui, it is where Guis are cloned from to the player when they spawn.

Fix:

script.Parent.Touched:connect(function(hit)
	local p = game.Players:GetPlayerFromCharacter(hit.Parent) -- gets the player
	if p then -- if the player exists (doesn't exist if not touched by a player)
		local text = p.PlayerGui.doorlocked.TextBox -- efficiency
		text.Visible = true
		wait(2)
		text.Visible = false
	end
end)

Explanations in code.

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