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: Could any one figure this out?

Previous Thread :: Next Thread 
materking1234 is not online. materking1234
Joined: 20 Nov 2008
Total Posts: 140
17 Mar 2016 07:18 AM
while true and wait() do
if script.check.Value == true then
for i,a in pairs (game.Workspace[script.setstat.Value].GroupA:GetChildren()) do
if a:IsA("BasePart") then
local mag = (a.Position - move.Position).magnitude
-- Right here, How would I get the least mag?
end
end
elseif script.check.Value == false then
wait()
end
end


--
How would I get the least mag? from those values it's getting from the mag?
Report Abuse
WoolHat is not online. WoolHat
Joined: 19 May 2013
Total Posts: 1873
17 Mar 2016 07:22 AM
while wait() do
if script.check.Value then
local currentmin = math.huge()
for i,a in pairs (game.Workspace[script.setstat.Value].GroupA:GetChildren()) do
if a:IsA("BasePart") then
local mag = (a.Position - move.Position).magnitude
currentmin = math.min(currentmin,mag)
end
end
print(currentmin)
end
end
Report Abuse
materking1234 is not online. materking1234
Joined: 20 Nov 2008
Total Posts: 140
17 Mar 2016 07:35 AM
: attempt to call field 'huge' (a number value)
Report Abuse
materking1234 is not online. materking1234
Joined: 20 Nov 2008
Total Posts: 140
17 Mar 2016 07:36 AM
Sorry, that is on the line with the math.huge()
Report Abuse
TheAwesomenessDude is not online. TheAwesomenessDude
Joined: 17 Jul 2011
Total Posts: 11602
17 Mar 2016 08:30 AM
make math.huge() into math.huge

no brackets
Report Abuse
R4G3N4R0K is not online. R4G3N4R0K
Joined: 16 Feb 2016
Total Posts: 74
17 Mar 2016 09:57 AM
while true and wait() do
local dist = 99 -- THE MAX MAG DISTANCE
if script.check.Value == true then
for i,a in pairs (game.Workspace[script.setstat.Value].GroupA:GetChildren()) do
if a:IsA("BasePart") then
local mag = (a.Position - move.Position).magnitude
if mag <= dist then
dist = mag
end
end
end
elseif script.check.Value == false then
wait()
end
end
Report Abuse
materking1234 is not online. materking1234
Joined: 20 Nov 2008
Total Posts: 140
17 Mar 2016 10:20 AM
I thank you people for caring to reply, but I don't think you're getting what I'm asking for.

The script is for docking. The "station" will have 4 max docking point a's.

For example. the structure would be something like

StationName(Model)
-DockingPoints(Model)
--PointA(Model)
---PointAA(Part)
---PointBA(Part)
---PointCA(Part)
---PointDA(Part)
--PointB(Model)
---PointAB(Part)
---PointBB(Part)
---PointCB(Part)
---PointDB(Part)

Now, the script gets the children in PointA, and gets the math, but needs to get the one that is the least furthest away, and for right now "Print" that value. for example, it would print PointCA in the output(if it was the closest point). However, I'm leaving it at as a "GetChildren" because I want to be able to use the script- for multiple stations without having to do a custom script for each one.

Then It moves to that point, gets its counter part (being PointCB) and move to that one.
Report Abuse
R4G3N4R0K is not online. R4G3N4R0K
Joined: 16 Feb 2016
Total Posts: 74
17 Mar 2016 10:12 PM
Mine will find the nearest one. :3
Report Abuse
WoolHat is not online. WoolHat
Joined: 19 May 2013
Total Posts: 1873
18 Mar 2016 05:09 AM
Revised, so it returns to actual closest part,instead of the smallest number. Also, not sure why you have this in a while loop. But I'll just comment it out

--while wait() and script.check.Value do
local currentmin = math.huge()
local nearestblock
for i,a in pairs (game.Workspace[script.setstat.Value].GroupA:GetChildren()) do
if a:IsA("BasePart") then
local mag = (a.Position - move.Position).magnitude
currentmin = math.min(currentmin,mag)
if currentmin == mag then
nearestblock = a
end
end
end
return nearestblock
--end
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