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
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)
Check out this wiki page - https://wiki.roblox.com/index.php?title=API:Class/BasePart/Touched