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:
1 | text = game.StarterGui:FindFirstChild( "ScreenGui" ) |
2 |
3 | script.Parent.Touched:connect( function () |
4 | text.TextLabel.Visible = true |
5 | wait( 3 ) |
6 | text.TextLabel.Visible = false |
7 | end ) |
Please help!
StarterGui
will only updated when the player dies. PlayerGui
will give live updates.
1 | script.Parent.Touched:connect( function (hit) --Defines hit as the person who touched it |
2 | if hit.Parent:FindFirstChild( 'Humanoid' ) then --Checks to make sure it's a player |
3 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) --Defines player |
4 | local text = player.PlayerGui:FindFirstChild( "ScreenGui" ) --Gets ScreenGui |
5 | text.TextLabel.Visible = true |
6 | wait( 3 ) |
7 | text.TextLabel.Visible = false |
8 | end |
9 | end ) |
Add a script into the part that you want to make the gui pop up and put this
1 | local Part = script.Parent |
2 |
3 | Part.Touched:connect( function (HIT) |
4 | local H = HIT.Parent:FindFirstChild( "Humanoid" ) |
5 | if H then |
6 | local Player = game.Players:GetPlayerFromCharacter(HIT.Parent) |
7 | Player.PlayerGui. --GuiStuffs--.Frame.Visible = true |
8 | end |
9 | end ) |
There Ya go