noah
|
  |
| Joined: 11 Sep 2006 |
| Total Posts: 18977 |
|
| |
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
noah
|
  |
| Joined: 11 Sep 2006 |
| Total Posts: 18977 |
|
| |
|
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
|
  |
| Joined: 11 Sep 2006 |
| Total Posts: 18977 |
|
| |
|
|
| 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
|
  |
| Joined: 11 Sep 2006 |
| Total Posts: 18977 |
|
| |
|
|
| 03 Jan 2013 09:07 PM |
Any output?
~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ 【▬】 |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 21 Mar 2008 |
| Total Posts: 3466 |
|
| |
|