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 |
|
|
|
| 24 Apr 2014 05:18 PM |
| You could use a BodyPosition/BodyVelocity/BodyForce topush the player away |
|
|
| Report Abuse |
|
|
Zeloi
|
  |
| Joined: 27 Sep 2010 |
| Total Posts: 1143 |
|
|
| 24 Apr 2014 05:19 PM |
@xXxMoNkEyMaNxXx
How would I do this? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 27 Sep 2010 |
| Total Posts: 1143 |
|
| |
|
|
| 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
|
  |
| 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
|
  |
| Joined: 27 Sep 2010 |
| Total Posts: 1143 |
|
| |
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 27 Sep 2010 |
| Total Posts: 1143 |
|
| |
|
|
| 24 Apr 2014 08:07 PM |
| Use the script I provided you, and modify that. Also, ALWAYS use local variables. |
|
|
| Report Abuse |
|
|
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 |
|
|