Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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!

1 comment

0

If this helped, then please accept my answer

2 answers

✓ Accepted answer

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)

2 comments

0

Thank you so much. This will definitely help me on my future endeavors. Thanks!

0

If this helped, then please accept my answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.