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 would i use magnitude on a part?

Previous Thread :: Next Thread 
noah is not online. noah
Joined: 11 Sep 2006
Total Posts: 18977
03 Jan 2013 07:54 PM
;o
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
03 Jan 2013 08:06 PM
what do you mean?

part.Size.magnitude
part.Position.magnitude

magnitude is a property of Vector3.

¬ LuaLearners Elite/Writer
Report Abuse
noah is not online. noah
Joined: 11 Sep 2006
Total Posts: 18977
03 Jan 2013 08:07 PM
um lets say i have dis wall and everytime time i'm close to it, i want the cancollide to be false. probably using magnitude cuz the script i hav sukz
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
03 Jan 2013 08:15 PM
local distance = 15

while wait() do
wall.CanCollide = not ((wall.Position - getNearestTorso(wall.Position).Position) < 15)
end

you'll have to figure out GetNearestTorso yourself, unless you want it to be just for you.


¬ LuaLearners Elite/Writer
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
03 Jan 2013 08:17 PM
Here's a way you can check if something is close to something else

local Dist = 10
function CheckMag(P1, P2)
return (P1.Position - P2.Position).magnitude <= Dist
end
Report Abuse
noah is not online. noah
Joined: 11 Sep 2006
Total Posts: 18977
03 Jan 2013 08:21 PM
will dis wurk?

wall = script.Parent
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
local distance = 15
if character and player.Name == "noah" then
if wall.Position - character.Torso(wall.Position).Position < distance then
wall.CanCollide = false
end
end
end)
end)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
03 Jan 2013 08:22 PM
if(wall.Position - character.Torso.Position).magnitude < distance then
Report Abuse
noah is not online. noah
Joined: 11 Sep 2006
Total Posts: 18977
03 Jan 2013 08:23 PM
ok thanks. i'm going to try it out
Report Abuse
noah is not online. noah
Joined: 11 Sep 2006
Total Posts: 18977
03 Jan 2013 08:30 PM
it doesn't work

wall = script.Parent
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
local distance = 15
if character and player.Name == "noah" then
if (wall.Position - character.Torso.Position).magnitude < distance then
wall.CanCollide = false
else
wall.CanCollide = true
end
end
end)
end)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
03 Jan 2013 08:31 PM
Output?
Report Abuse
noah is not online. noah
Joined: 11 Sep 2006
Total Posts: 18977
03 Jan 2013 08:33 PM
no output
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
03 Jan 2013 08:35 PM
Make sure it's NOT a local script
Report Abuse
noah is not online. noah
Joined: 11 Sep 2006
Total Posts: 18977
03 Jan 2013 08:35 PM
its not
Report Abuse
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
03 Jan 2013 08:58 PM
wall = script.Parent

for _, v in pairs(game.Players:GetChildren()) do
local distance = 15
if v.Name == "noah" and v.Character then
if (wall.Position - v.Character.Torso.Position).magnitude < distance then
wall.CanCollide = false
else
wall.CanCollide = true
end
end
wait()
end

~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ 【▬】
Report Abuse
noah is not online. noah
Joined: 11 Sep 2006
Total Posts: 18977
03 Jan 2013 09:06 PM
still doesnt wurk
Report Abuse
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
03 Jan 2013 09:07 PM
Any output?

~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ 【▬】
Report Abuse
rayoma is not online. rayoma
Joined: 13 Nov 2009
Total Posts: 1911
03 Jan 2013 09:10 PM
The way you have your script set up it will only work if you spawn within a close distance from the wall. You have to loop it to continuously check if your character is close enough to open the door.

local wall = script.Parent
local distance = 15

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
if player.Name=="noah" then
while character and character:findFirstChild("Torso") do
Wait(0.2);
if (wall.Position - character.Torso.Position).magnitude < distance then
wall.CanCollide = false
else
wall.CanCollide = true
end
end
end
end)
end)
Report Abuse
noah is not online. noah
Joined: 11 Sep 2006
Total Posts: 18977
03 Jan 2013 09:24 PM
@ray;
thanks, your script worked perfectly

@others
i appreciate all ur help
Report Abuse
doneyes is not online. doneyes
Joined: 21 Mar 2008
Total Posts: 3466
03 Jan 2013 09:34 PM
I think this is what you want:

This is how you print the distance between two parts the easy way. (distance betweem part1 and pablo)

anyvariable = (part1.Position - pablo.Position).magnitude

print(anyvariable)
Report Abuse
doneyes is not online. doneyes
Joined: 21 Mar 2008
Total Posts: 3466
03 Jan 2013 09:34 PM
/floodcheck
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