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. :/
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. :/
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.
1 comment
Code block.