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

How to make if block touched frame goes visible?

So, I am making a game like "The complex v7". I throwback.. and in a certain part of the game you need to touch a part.. and then ScreenGui.Frame.Visible = true

so I tried

script.Parent.Touched:connect(Function) Game.StarterGui.ScreenGui.Frame.Visible = true end)

but that doesn't work..

can somebody please help me with this? I really need this!

2 answers

Hey there. There's a big flaw with your code. Simple fix though. You can't index into StarterGui, which is why you have to do something different. You also have to put the code inside your function, not outside of it.

What I want you to do, is insert a LocalScript into your Frame. What a localscript does, is runs locally, so the frame wont appear on everyones frame.

Code:

local Frame = script.Parent --reference variable for the frame, which is script.Parent

Frame.Visible = false --makes the frame disappear in the beginning

game.Workspace.PARTNAME.Touched:Connect(function() --if your part it touched, then this function should run
	Frame.Visible = true --make the frame visible
end)

Make sure to change PARTNAME, to your parts name, you want the Player to touch. Please try to understand the code, as it's better for you. I also highly suggest you try to learn scripting, because it will help you a LOT. Hope I helped, and have a good day.

5 comments

0

Thank you so much! and I do know coding just not as much.. I will try this now. thank you and have a good day

0

No problem, have a wonderful day.

0

It doesn't work.. can you add me as a friend so I can invite you so you can help me with this?

0

it didnt work

0

It should work. Make sure it's a localscript and it's in your frame, and make sure to set PARTNAME to your part's name.

This is very simple! Insert a LocalScript into your Frame and type the following script:

local Part = workspace.PARTNAME
local Frame = script.Parent

Frame.Visible = false --this just makes it invisible from the beginning

Part.Touched:Connect(function() -- detects when its touched
	Frame.Visible = true --makes it visible
end)

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