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: .Magnitude PLEASE HELP!!!

Previous Thread :: Next Thread 
Zeloi is not online. Zeloi
Joined: 27 Sep 2010
Total Posts: 1143
24 Apr 2014 05:16 PM
So basically I'm making a force field that flings you away from it and I need help with the fling and I thought that magnitude would be the best way, the only problem is HOW DO I USE IT????

So I came to the forum

MAIN
==========
How would I ge the player to fling about 20-50 studs away from the part?

I don't have something for you guys to debug I just need some help with the whole thing.

Thanks for reading!

If you have an answer, PLEASE post it below!
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
24 Apr 2014 05:18 PM
You could use a BodyPosition/BodyVelocity/BodyForce topush the player away
Report Abuse
Zeloi is not online. Zeloi
Joined: 27 Sep 2010
Total Posts: 1143
24 Apr 2014 05:19 PM
@xXxMoNkEyMaNxXx

How would I do this?
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
24 Apr 2014 05:22 PM
I have a feeling that BodyVelocity would work the best.

Break it down into steps like this:
1. find out if a player is too close
2. if yes, then put a new BodyVelocity in their torso
3. Set the velocity to away from the place they shouldn't be and wait a few seconds
4. remove the BodyVelocity
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
24 Apr 2014 05:23 PM
Actually, It would work even better if you set Humanoid.PlatformStand to true when you put in the BodyVelocity.
Report Abuse
COOLDUDE11OO is not online. COOLDUDE11OO
Joined: 21 Aug 2011
Total Posts: 5115
24 Apr 2014 05:28 PM
while wait() do
for i,v in pairs(game.Players:GetChildren()) do
if (v.Character.Torso.Position - script.Parent.Position).magnitude <= 10 then
v.Character.Torso.Velocity = 1000 --????
end
end
end
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
24 Apr 2014 05:30 PM
while wait(1/10) do
for i,v in pairs(game.Players:GetChildren()) do
if (v.Character.Torso.Position - script.Parent.Position).Magnitude <= 10 then
v.Character.Torso.Velocity = (v.Character.Torso.Position - script.Parent.Position).Unit * 1000
end
end
end
Report Abuse
Zeloi is not online. Zeloi
Joined: 27 Sep 2010
Total Posts: 1143
24 Apr 2014 05:32 PM
didn't work
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
24 Apr 2014 05:34 PM
That would break when someone joins the game because they wouldn't have a character, and it would also break because 1000 is not a Vector3. You can see the steps taken easily though.

local ForceFieldCentre=script.Parent
local Players=game:GetService'Players'
while wait() do
for i,v in next,Players:GetPlayers() do
if v.Character and v.Character:findFirstChild'Torso' and (v.Character.Torso.Position - ForceFieldCentre.Position).magnitude <= 10 then
v.Character.Torso.Velocity = (v.Character.Torso.Position - ForceFieldCentre.Position).unit*1000 --Lower this number if it's too strong
end
end
end
Report Abuse
Zeloi is not online. Zeloi
Joined: 27 Sep 2010
Total Posts: 1143
24 Apr 2014 05:38 PM
RoflBread THANKS SO MUCH ITS AMAZING

I'd just like to know how it works please.
Report Abuse
Zeloi is not online. Zeloi
Joined: 27 Sep 2010
Total Posts: 1143
24 Apr 2014 05:42 PM
HOW DOES IT WORK ????????
Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
24 Apr 2014 05:44 PM
while wait(1/10) do --Loops one tenth of a second each time
for i,v in pairs(game.Players:GetChildren()) do --Gets all the players
if (v.Character.Torso.Position - script.Parent.Position).Magnitude <= 10 then --If the magnitude of the character's torso position minus the script parent's position is below or equal to 10 then
v.Character.Torso.Velocity = (v.Character.Torso.Position - script.Parent.Position).Unit * 1000 --Fling the player back by the unit of the character's torso position minus the script parent's position, multiplied by the force, which is 1000.
end
end
end

Here's my siggy... Done.
Report Abuse
Zeloi is not online. Zeloi
Joined: 27 Sep 2010
Total Posts: 1143
24 Apr 2014 05:45 PM
I said it works I just need an explanation like a tip or something just need to know how it works
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
24 Apr 2014 05:45 PM
Bit late for me to explain today, but it's just some simple vector math. I'll explain tomorrow if I'm on tommorow.
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
24 Apr 2014 05:46 PM
Chillax

1. find out if a player is too close
2. Set the velocity of their torso to away from the place they shouldn't be
Report Abuse
Zeloi is not online. Zeloi
Joined: 27 Sep 2010
Total Posts: 1143
24 Apr 2014 06:05 PM
Ok it works but I have a thing that takes 35 damage away from the character but it takes like 70 how would one fix this?
Report Abuse
Zeloi is not online. Zeloi
Joined: 27 Sep 2010
Total Posts: 1143
24 Apr 2014 07:55 PM
how come this doesn't work???

debounce = false
for i,v in pairs (game.Players:GetChildren()) do
while (v.Character.Torso.Position - script.Parent.Position).Magnitude <= 6 and not debounce do
human = hit.Parent:FindFirstChild("Humanoid")
debounce = true
v.Character.Torso.Velocity = (v.Character.Torso.Position - script.Parent.Position).Unit * 225
v.Character.Humanoid.PlatformStand = true
human.Health = human.Health - 10
for i = 0.3, 0.95, 0.01 do
wait()
script.Parent.Transparency = i
end
wait(2)
v.Character.Humanoid.PlatformStand = false
debounce = false
end
end
Report Abuse
Zeloi is not online. Zeloi
Joined: 27 Sep 2010
Total Posts: 1143
24 Apr 2014 07:57 PM
New version (still doesn't work)

debounce = false
for i,v in pairs (game.Players:GetChildren()) do
while (v.Character.Torso.Position - script.Parent.Position).Magnitude <= 6 and not debounce do
debounce = true
v.Character.Torso.Velocity = (v.Character.Torso.Position - script.Parent.Position).Unit * 225
v.Character.Humanoid.PlatformStand = true
v.Character.Humanoid.Health = v.Character.Humanoid.Health - 10
for i = 0.3, 0.95, 0.01 do
wait()
script.Parent.Transparency = i
end
wait(2)
v.Character.Humanoid.PlatformStand = false
debounce = false
end
end
Report Abuse
Zeloi is not online. Zeloi
Joined: 27 Sep 2010
Total Posts: 1143
24 Apr 2014 08:04 PM
Bump
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
24 Apr 2014 08:07 PM
Use the script I provided you, and modify that. Also, ALWAYS use local variables.
Report Abuse
Zeloi is not online. Zeloi
Joined: 27 Sep 2010
Total Posts: 1143
24 Apr 2014 08:14 PM
Thanks monkey!

your a great scripter you should make a game!
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