generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: i need help with script

Previous Thread :: Next Thread 
iNeoR is not online. 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 is not online. iNeoR
Joined: 03 Jun 2017
Total Posts: 60
20 Aug 2017 02:41 PM
bump
Report Abuse
McRocketNuggets is not online. McRocketNuggets
Joined: 23 Nov 2016
Total Posts: 472
20 Aug 2017 02:42 PM
http://wiki.roblox.com/index.php?title=Magnitude
Report Abuse
doggy00 is online. 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 is not online. iNeoR
Joined: 03 Jun 2017
Total Posts: 60
20 Aug 2017 03:07 PM
thanks!

bump2
Report Abuse
iNeoR is not online. iNeoR
Joined: 03 Jun 2017
Total Posts: 60
20 Aug 2017 03:08 PM
i mean screen gui
Report Abuse
Zued is online. Zued
Joined: 18 May 2015
Total Posts: 506
20 Aug 2017 04:00 PM
local magnitude = (part1.Position - part2.Position).magnitude


Report Abuse
doggy00 is online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image