local Fling = {}
local Players = game.Players:GetPlayers()
Fling.Fling = function(Character, Point, WaitTime)
require(game.ReplicatedStorage.Modules.Ragdoll).Ragdoll(Character)
for _, Player in pairs(Players) do
if not Character then
continue
end
local Root = Character:FindFirstChild("HumanoidRootPart")
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
local FlingDirection = CFrame.new(Point, Root.Position).LookVector
local BodyVelocity = Instance.new("BodyVelocity", Character.Torso)
BodyVelocity.Velocity = FlingDirection*100
task.wait(0.2)
BodyVelocity:Destroy()
end
task.wait(WaitTime)
require(game.ReplicatedStorage.Modules.Ragdoll).UnRagdoll(Character)
end
return Fling
I made this fling scripter after i got ragdolling working, it works fine besides 1 issue, id like the force applied to me less and less the further you are away from the “Point”
you should calculate the distance between the character and the point, then scale the velocity/force
something like this;
local Fling = {}
local Players = game.Players:GetPlayers()
Fling.Fling = function(Character, Point, WaitTime)
require(game.ReplicatedStorage.Modules.Ragdoll).Ragdoll(Character)
for _, Player in pairs(Players) do
if not Character then continue end
local Root = Character:FindFirstChild("HumanoidRootPart")
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
if not Root then continue end
local FlingDirection = CFrame.new(Point, Root.Position).LookVector
local distance = (Root.Position - Point).Magnitude
local strength = 200 / distance
local BodyVelocity = Instance.new("BodyVelocity", Character.Torso)
BodyVelocity.Velocity = FlingDirection * strength
task.wait(0.2)
BodyVelocity:Destroy()
end
task.wait(WaitTime)
require(game.ReplicatedStorage.Modules.Ragdoll).UnRagdoll(Character)
end
return Fling
adjust local strength as needed
alternatively if you want a minimum or a max on strength (which is recommended if you are playing around with roblox physics) you can do
local strength = math.clamp(200 / distance, 20, 100)
where 20 is the minimum number and 100 is the maximum number
had ot make a small change with this that i forgot to make, anyways, how would i add a variable that controlls how strong the fling is? (changing both the max distance and fling power with the same value)
local Fling = {}
local Players = game.Players:GetPlayers()
Fling.Fling = function(Character, Point, WaitTime)
require(game.ReplicatedStorage.Modules.Ragdoll).Ragdoll(Character)
for _, Player in pairs(Players) do
if not Character then continue end
local Root = Character:FindFirstChild("HumanoidRootPart")
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
if not Root then continue end
local FlingDirection = CFrame.new(Point, Root.Position).LookVector
local distance = (Root.Position - Point).Magnitude
local strength = 200 / distance
local BodyVelocity = Instance.new("BodyVelocity", Character.Torso)
BodyVelocity.Velocity = FlingDirection * strength
task.wait(0.05)
BodyVelocity:Destroy()
end
task.wait(WaitTime)
require(game.ReplicatedStorage.Modules.Ragdoll).UnRagdoll(Character)
end
return Fling
I mean something like:
function(Character, Point, WaitTime, Power)
i changed my mind, id like to be able o change the power and maxdistance individually, how would i make it so if the player is out of the maxdistance, it wont ragdoll them at all? Also, would the max distance be able to be set in studs?