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
7 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 7 years ago
Edited 7 years ago

In a LocalScript in StarterGui:

local player = game.Players.LocalPlayer
local char = player.Character
if(char.Torso.Position - game.Workspace.Part.Position).Magnitude <= 10 then
    print("Character is 10 or less studs away from part")
end
0
I don't see the reason for a print. TRILLFLOWS 135 — 7y
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 — 7y
0
Can you please accept this answer? happyturk4 33 — 7y
Ad
Log in to vote
0
Answered by 7 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:

GUI = game.Players.LocalPlayer.PlayerGui.GUINAME

script.Parent.Touched:connect(function()
              if GUI.Visible == false then
                         GUI.Visible =true 
           wait(5)
                  GUI.Visible = false
          end
end)

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