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

How do I make a help box brick that temporarily turns on a text box?

I would like to make it so that when someone steps on a brick, it makes GUI visible for 5 seconds then turns it off. This is the code I have so far. I know how to toggle the GUI, but I have no idea on how to sense touch by a humanoid. I’m fairly new to scripting.

Double = game.StarterGui.ScreenGui.Double

Double.Visible = true
Wait(300)
Double.Visible = False

end

2 answers

Since you're so new to coding you can't even figure out how to make a touch block that detects humanoids, I really recommend starting over and learning the fundamentals of Roblox Lua. You will only slow yourself down if you get advanced way too fast.

Anyways, here's a relatively dumbed-down way to "make a help box brick that temporarily turns on a text box".

Before you read the script, create a RemoteEvent named OpenTextBox in ReplicatedStorage. The LocalScript seen below should be put in >StarterPlayer>StarterCharacterScripts

LOCAL SCRIPT

StarterGui = game:WaitForChild("StarterGui")
screenGui = StarterGui:WaitForChild("ScreenGui")

Double = screenGui:WaitForChild("Double") -- I would change "Double" into "textBox".

openTextBox = game.ReplicatedStorage:WaitForChild("OpenTextBox")

openTexBox.OnClientEvent:Connect(function(openFor)
	Double.Visible = true
	wait(openFor)
	Double.Visible = false
end)

Now you're going to create a Part in the workspace named Help Box Also, create a new Script inside of the Part you just made.

SCRIPT

helpBox = script.Parent
openTextBox = game.ReplicatedStorage:WaitForChild("OpenTextBox")

helpBox.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then -- if humanoid touched the brick
		if game.Players:GetPlayerFromCharacter(hit.Parent) then -- if humanoid is a player
			openTextBox:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent))
		end
	end
end)

1 comment

0

This looks promising

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