Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I'm trying to get text to pop up when I touch something, but it doesn't pop up. Why?

Asked by 8 years ago
Edited 8 years ago

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:

1text = game.StarterGui:FindFirstChild("ScreenGui")
2 
3script.Parent.Touched:connect(function()
4    text.TextLabel.Visible = true
5    wait(3)
6    text.TextLabel.Visible = false
7end)

Please help!

0
If this helped, then please accept my answer Async_io 908 — 8y

2 answers

Log in to vote
1
Answered by
Async_io 908 Moderation Voter
8 years ago

StarterGui will only updated when the player dies. PlayerGui will give live updates.

1script.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
9end)
0
Thank you so much. This will definitely help me on my future endeavors. Thanks! MustangHeart 67 — 8y
0
If this helped, then please accept my answer Async_io 908 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

Add a script into the part that you want to make the gui pop up and put this

1local Part = script.Parent
2 
3Part.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
9end)

There Ya go

Answer this question