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 » Scripting Helpers
Home Search
 

Re: How can I find how far away an object is

Previous Thread :: Next Thread 
RealPersian is not online. RealPersian
Joined: 03 Oct 2011
Total Posts: 185
20 Oct 2012 04:19 PM
I want add a script that turns a brick a different blue after a person goes a certain distance away from another brick.

I know this isn't right, but something along the lines of:

if RealPersian.Distancefrombrick ​> 40 then
brick.Color= BrickColor.new("Blue")
end

How can it be done?
Report Abuse
michaelaqz4 is not online. michaelaqz4
Joined: 23 Sep 2009
Total Posts: 1940
20 Oct 2012 04:22 PM
Thats funny I just made a script that can do just this (With a little editing)
I'll edit it and post it :)
Report Abuse
grimm343 is not online. grimm343
Joined: 18 Sep 2008
Total Posts: 2796
20 Oct 2012 04:30 PM
Use .magnitude when subtracting two Vector3 positions.

Example:

print((Wokspace.Part.Position-Workspace.grimm343.Torso.Position).magnitude)
Report Abuse
michaelaqz4 is not online. michaelaqz4
Joined: 23 Sep 2009
Total Posts: 1940
20 Oct 2012 04:32 PM
Find = script.Parent.Parent.Name
Part = Brick
while true do
wait(1)
if
workspace[Find].Torso.Position.X < workspace.Part.Position.X + 10
and workspace[Find].Torso.Position.X > workspace.Part.Position.X - 10
and workspace[Find].Torso.Position.Z < workspace.Part.Position.Z + 10
and workspace[Find].Torso.Position.Z > workspace.Part.Position.Z - 10 then
print("Your safe, For now!")
wait(1)
else
workspace.Part.Color = BrickColor.new("Blue")
wait(0)
end
end


Somethings wrong with the part that changes the color, Im not good at that kind of stuff sorry! Just fix the color and it will work

(Put the script in the starterGUI)
Report Abuse
Joalmo is not online. Joalmo
Joined: 28 Jun 2009
Total Posts: 1160
20 Oct 2012 05:13 PM
machaelaqz4, that script is wayyy too over-complicated.

distanceBetweenParts = ((Part1.Position) - (Part2.Position)).magnitude
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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