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: Magnitude Update

Previous Thread :: Next Thread 
Alfa247 is not online. Alfa247
Joined: 15 Jan 2010
Total Posts: 118
09 Oct 2016 07:09 AM
Just like when a block is hit.
game.Workspace.Baseplate.Touched:connect(function()
--CODE
end)

Is there on for when a player is within a certain magnitude in an area without putting it through a while script.

while wait(.1) do
players = game.Players:GetChildren()
for i,v in pairs(players) do
player_torso = v.Character.Torso
player = v.Character

if ((script.Parent.Torso.Position-player_torso.Position).magnitude <= 15) then

print ("TEXT HERE")
Report Abuse
nooneisback is not online. nooneisback
Joined: 28 Feb 2012
Total Posts: 1672
09 Oct 2016 08:56 AM
You could try creating an invisible sphere with a touch event.
Report Abuse
Gentaurg is not online. Gentaurg
Joined: 19 Mar 2011
Total Posts: 8648
09 Oct 2016 09:32 AM
you could do .Changed on the player's position (it will run every time you move)
then you check if the character is within distance of the object
Report Abuse
nooneisback is not online. nooneisback
Joined: 28 Feb 2012
Total Posts: 1672
09 Oct 2016 09:49 AM
That would work, yet that might be pretty laggy, especially when there are multiple players. While my solution will fire only once.
Report Abuse
Gentaurg is not online. Gentaurg
Joined: 19 Mar 2011
Total Posts: 8648
09 Oct 2016 11:14 AM
it's a pretty small calculation... you wont ever notice it
Report Abuse
Gentaurg is not online. Gentaurg
Joined: 19 Mar 2011
Total Posts: 8648
09 Oct 2016 11:15 AM
or maybe you would
Report Abuse
vectorGunner is not online. vectorGunner
Joined: 23 Mar 2014
Total Posts: 784
09 Oct 2016 11:23 AM
You could calculate it yourself using removing sqrt from it. Since it isn't useful to have the actual stud magnitude unless your displaying it to the player.

So... something like...

local v = pos2-pos1
local mag = v.x*v.x+v.y*v.y+v.z*v.z

if dist^2 < mag then
--in circle
end
Report Abuse
vectorGunner is not online. vectorGunner
Joined: 23 Mar 2014
Total Posts: 784
09 Oct 2016 11:31 AM
Btw my thing was just speeding up the on update solution, a sphere with OnTouch event though is probably the best solution.
Report Abuse
nooneisback is not online. nooneisback
Joined: 28 Feb 2012
Total Posts: 1672
09 Oct 2016 03:37 PM
Or a combination of both? When the player hits the sphere a loop starts, calculating the distance and sending it to where ever it's needed, and the loop breaks when touch has ended.
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