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 7 years ago
Edited 7 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:

text = game.StarterGui:FindFirstChild("ScreenGui")

script.Parent.Touched:connect(function()
    text.TextLabel.Visible = true
    wait(3)
    text.TextLabel.Visible = false
end)

Please help!

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

2 answers

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

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

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

Answer this question