Hello there. When I try touch an invisible block to allow text to appear (inside of a screengui), nothing pops up. I used the on touch command, and nothing works. Here is my code:
text = game.StarterGui:FindFirstChild("ScreenGui") script.Parent.Touched:connect(function() text.TextLabel.Visible = true wait(3) text.TextLabel.Visible = false end)
Please help!
StarterGui
will only updated when the player dies. PlayerGui
will give live updates.
script.Parent.Touched:connect(function(hit) --Defines hit as the person who touched it if hit.Parent:FindFirstChild('Humanoid') then --Checks to make sure it's a player local player = game.Players:GetPlayerFromCharacter(hit.Parent) --Defines player local text = player.PlayerGui:FindFirstChild("ScreenGui") --Gets ScreenGui text.TextLabel.Visible = true wait(3) text.TextLabel.Visible = false end end)
Add a script into the part that you want to make the gui pop up and put this
local Part = script.Parent Part.Touched:connect(function(HIT) local H = HIT.Parent:FindFirstChild("Humanoid") if H then local Player = game.Players:GetPlayerFromCharacter(HIT.Parent) Player.PlayerGui.--GuiStuffs--.Frame.Visible = true end end)
There Ya go