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

How do I make a GUI appear when a player is in range?

Asked by
chrono2 189
8 years ago

I'm making batman!

And I want the player to be able to grapple to some specific bricks when they get close enough to them by pressing a button. Think the grapple mechanic in the Arkham games, but more limited.

I want to have an indicator GUI appear when a player is in range of a brick they can grapple onto which will point them to the direction of the brick and demonstrate where it is--again, think Arkham. How would I do that?

2 answers

Log in to vote
2
Answered by 8 years ago
Edited 8 years ago

In a LocalScript in StarterGui:

1local player = game.Players.LocalPlayer
2local char = player.Character
3if(char.Torso.Position - game.Workspace.Part.Position).Magnitude <= 10 then
4    print("Character is 10 or less studs away from part")
5end
0
I don't see the reason for a print. TRILLFLOWS 135 — 8y
0
It is just an example, instead of the print do the gui.Visible = true, and do an else and do gui.Visible = false RoyMer 301 — 8y
0
Can you please accept this answer? happyturk4 33 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

What you can do is just set parts in certain points and create onTouched function to get the GUI to pop up

Example:

1GUI = game.Players.LocalPlayer.PlayerGui.GUINAME
2 
3script.Parent.Touched:connect(function()
4              if GUI.Visible == false then
5                         GUI.Visible =true
6           wait(5)
7                  GUI.Visible = false
8          end
9end)

This was done on a phone so it is not sorted with tabs but instead sorted with spaces please rearrange the code

Please be Sure to ACCEPT this answer :)

Answer this question