iNeoR
|
  |
| Joined: 03 Jun 2017 |
| Total Posts: 60 |
|
|
| 20 Aug 2017 02:36 PM |
| so how do i make it so that the button that makes the gui shop appear only visible if the player is close to a part? like for example theres a shop merchant model and the button can only appear if the player is standing close enough to the merchant? help... and thats the best i can explain :p |
|
|
| Report Abuse |
|
|
iNeoR
|
  |
| Joined: 03 Jun 2017 |
| Total Posts: 60 |
|
| |
|
|
| 20 Aug 2017 02:42 PM |
| http://wiki.roblox.com/index.php?title=Magnitude |
|
|
| Report Abuse |
|
|
doggy00
|
  |
| Joined: 11 Jan 2011 |
| Total Posts: 3571 |
|
|
| 20 Aug 2017 02:52 PM |
On-screen button (ScreenGui) or on-part button (SurfaceGui)?
Either way, you'd just use magnitude or even an invisible ball object as a hitbox along with .Touched to determine if they are close enough. There are pages on magnitude and on .Touched events in ROBLOX's official wiki at wiki.roblox.com. |
|
|
| Report Abuse |
|
|
iNeoR
|
  |
| Joined: 03 Jun 2017 |
| Total Posts: 60 |
|
| |
|
iNeoR
|
  |
| Joined: 03 Jun 2017 |
| Total Posts: 60 |
|
| |
|
Zued
|
  |
| Joined: 18 May 2015 |
| Total Posts: 506 |
|
|
| 20 Aug 2017 04:00 PM |
local magnitude = (part1.Position - part2.Position).magnitude
|
|
|
| Report Abuse |
|
|
doggy00
|
  |
| Joined: 11 Jan 2011 |
| Total Posts: 3571 |
|
|
| 21 Aug 2017 02:52 PM |
You could have a local script inside of the main GUI object of the ScreenGui (say, put a frame in the ScreenGui and insert everything in that frame along with this script) which looks something like this:
guipart = workspace:WaitForChild("guipart") --of course you'd change the name/location
while wait(.1337) do
if guipart then
player = game.Players.LocalPlayer char = player.Character
if char then
root = char:FindFirstChild("HumanoidRootPart")
if root then
magnitude = (guipart.Position - root.Position).magnitude
if magnitude <= 20 then --change 20 to the range in studs
script.Parent.Visible = true
else
script.Parent.Visible = false
end
end
end
end
end
--This is untested and quickly written so it may not work, but you get the idea. |
|
|
| Report Abuse |
|
|