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: RE:

Previous Thread :: Next Thread 
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
31 Dec 2011 11:45 AM
I wanna make something with magninitude. i dont know how i use it. So as exemple. BlockA searches for blocks with magnitude = 1, theres a BlockB with magnitude = 1. How can i script that ?
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
31 Dec 2011 11:51 AM
do you know what i mean ?
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
31 Dec 2011 12:04 PM
Pls Guys heeelp me
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
31 Dec 2011 12:14 PM
no idea ?
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
31 Dec 2011 12:23 PM
Hello.

First, we must grasp the concept of the magnitude property. The magnitude property can is a member of a Vector3 data type or Vector2 data type. What this property does is give you the length of the Vector3/2. So.. please rephrase your question so I can give you some sample code. :)

~Flurite
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
31 Dec 2011 12:27 PM
hmm maybe then magnitude is the wrong thing... so lets make a pseudocode:

Theres a BlockA and BlockB

Get all blocks with distance 1 from BlockA

Returns BlockB

Maybe you understand know what im searching for. Sry for my bad English im swiss.
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
31 Dec 2011 12:43 PM
got it ?
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
31 Dec 2011 12:45 PM
Actually, you are talking about the right thing. Here is an example that loops through all of Workspace finding all bricks that are within 1 stud away from BlockA. It will return a table..

blockA = game.Workspace.BlockA

function GetNearbyBricks(brick)
local nearbyBricks = {}
for index, child in pairs(game.Workspace:GetChildren()) do
if child:IsA("BasePart") and (Vector3.new(blockA.Position) - Vector3.new(child.Position).magnitude <= 1 then
table.insert(nearbyBricks, child)
end
end
return nearbyBricks
end

~Flurite
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
31 Dec 2011 12:50 PM
> (Vector3.new(blockA.Position) - Vector3.new(child.Position).magnitude <= 1

um what?

    (blockA.Position-child.Position).magnitude

You screwed that part up really badly. Also I would add a bit of a fuzz factor to the 1.
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
31 Dec 2011 12:50 PM
HOW COOL :D thx i will test it right now :DDDD one question. When all Objects are in one table, how can i "activate" them ? e.x. change their transpirancy
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
31 Dec 2011 12:51 PM
e.g. not e.x. sorry :)
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
31 Dec 2011 12:53 PM
@rasta
With the fixes I pointed out, just do like this.

    local parts=GetNearbyBricks(blockA)
    
    for _,v in pairs(parts) do
        v.Transparency=0.5;--or whatever you want here
    end
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
31 Dec 2011 12:53 PM
Ok Duke you confused me xD
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
31 Dec 2011 12:53 PM
for index, value in pairs(TableName) do
if value:IsA("BasePart") then value.Transparency = 0.5 end
end
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
31 Dec 2011 01:00 PM
Could someone pls post the whole Exemple ? im really confused xD
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
31 Dec 2011 01:18 PM
bump
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
31 Dec 2011 02:09 PM
Just a whole exemple please. Everyone above doesnt work
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
31 Dec 2011 02:20 PM
Well my way is kinda long, but all I forgot a parenthesis..

blockA = game.Workspace.BlockA

function GetNearbyBricks(brick)
local nearbyBricks = {}
for index, child in pairs(game.Workspace:GetChildren()) do
if child:IsA("BasePart") and (Vector3.new(blockA.Position) - Vector3.new(child.Position)).magnitude <= 1 then
table.insert(nearbyBricks, child)
end
end
return nearbyBricks
end

~Flurite
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
31 Dec 2011 02:22 PM
@flurite
position is already a Vector3 value so there's no reason to change it into a Vector3.
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
31 Dec 2011 02:38 PM
@Sduke

Oh yeah.. it works though. =/

@rasta

This is your transparency script:

blockA = game.Workspace.BlockA

function GetNearbyBricks(brick)
for index, child in pairs(game.Workspace:GetChildren()) do
if child:IsA("BasePart") and (Vector3.new(blockA.Position) - Vector3.new(child.Position)).magnitude <= 1 then
child.Transparency = 0.5
end
end
end

~Flurite
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
31 Dec 2011 02:44 PM
Its does nothing, no output no transparency xD
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
31 Dec 2011 02:51 PM
Oh yeah, make sure one brick is named BlockA, and the brick you want to be transparent is RIGHT NEXT to it.

~Flurite
Report Abuse
rastamann is not online. rastamann
Joined: 27 May 2008
Total Posts: 539
31 Dec 2011 02:52 PM
Yep thats what i did xD
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
31 Dec 2011 02:54 PM
OOPS, you gotta call the function. x.x

blockA = game.Workspace.BlockA

function GetNearbyBricks(brick)
for index, child in pairs(game.Workspace:GetChildren()) do
if child:IsA("BasePart") and (Vector3.new(brick.Position) - Vector3.new(child.Position)).magnitude <= 1 then
child.Transparency = 0.5
end
end
end

GetNearbyBricks(blockA)

~Flurite
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
31 Dec 2011 02:56 PM
OKAY USE THIS SCRIPT. I ADDED A PART SO IT DOESNT MAKE ITSELF TRANSPARENT. X_X

blockA = game.Workspace.BlockA

function GetNearbyBricks(brick)
for index, child in pairs(game.Workspace:GetChildren()) do
if child:IsA("BasePart") and (Vector3.new(brick.Position) - Vector3.new(child.Position)).magnitude <= 1 and child ~= brick then
child.Transparency = 0.5
end
end
end

GetNearbyBricks(blockA)

~Flurite
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