Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make if block touched frame goes visible?

Asked by 3 years ago

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

Log in to vote
4
Answered by 3 years ago

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.

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 TheRealJaytjie 0 — 3y
0
No problem, have a wonderful day. gamernight687 138 — 3y
0
It doesn't work.. can you add me as a friend so I can invite you so you can help me with this? TheRealJaytjie 0 — 3y
0
it didnt work TheRealJaytjie 0 — 3y
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. gamernight687 138 — 3y
Ad
Log in to vote
1
Answered by 3 years ago

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)

Answer this question