How would I replicate this in a function? I tried it, but I noticed that BodyForces are deprecated and you should use LinearForces instead. How would I script this fling effect with a non-deprecated method + how would I be able to sit the player while he is flinging + how to “spin” him while he’s flinging (video, the spinning like effect)?
Help is very much appreciated, ive searched through YouTube, DevForum and lots more for assistance guides, didn’t find any sadly…
There are probably lots of ways but the simplest way I can think of would be to set the players current state to sitting, turn on platformstand and use applyImpulse on the humanoidrootpart with a big vector3 kinda like vector3.new(math.random(-10000,10000),math.random(-10000,10000),math.random(-10000,10000)). this is just a theory and I haven’t tested it so it might not work if you were to put it into actual code.
I did testing and found out that wouldnt work, I did make a fling like system that did fling the player but ran into the problem you made this post to find, which is the rotating. the player wouldnt rotate, and I’ve never needed to do that so I don’t know how to make it do that.
I think you need to add a AngularVelocity to the character, its icon is a spinny wheel so probably, maybe you can rapidly add angular velocities with random numbers to the player to make them spin
it’s my first time ever using angular velocity so I thought if I leave it in, it will work correctly but I just tested it out by deleting it right after creating it and I think it gave the desired result
Note: also the player should MOST DEFINENTLY not be able to fling themselves while being flung, thats why im turning into a fidget spinner.
angular velocity, heres the angular velocity code.
local function attachmentCreater(name, parent, offset)
local parentCFrame = parent.CFrame
local att = Instance.new("Attachment")
att.Parent = parent
att.Name = name
att.WorldCFrame = parentCFrame * offset
return att
end
local av = Instance.new("AngularVelocity")
av.Parent = humanoidRootPart
av.MaxTorque = 10000
av.ReactionTorqueEnabled = false
local att1 = attachmentCreater("att1", humanoidRootPart, CFrame.new(0,0,0))
local att2 = attachmentCreater("att2", humanoidRootPart, CFrame.new(0,0,0))
game.Debris:AddItem(att1,.1)
game.Debris:AddItem(att2,.1)
game.Debris:AddItem(av,.1)
av.Attachment0 = att1
av.Attachment1 = att2
av.AngularVelocity = Vector3.new(math.random(-20,20),math.random(-20,20),math.random(-20,20))
all you need to do is turn on the platform stand property in humanoid, add a bodyvelocity and an angular velocity. (body velocity is for the actual flinging part the angular velocity is for rotation)
task.wait(.5)
local uis = game:GetService("UserInputService")
local flingKey = Enum.KeyCode.H
uis.InputBegan:Connect(function(key, proc)
if not proc and key.KeyCode == flingKey then
script.Fling:FireServer()
end
end)
Server:
local function attachmentCreater(name, parent, offset)
local parentCFrame = parent.CFrame
local att = Instance.new("Attachment")
att.Parent = parent
att.Name = name
att.WorldCFrame = parentCFrame * offset
return att
end
local function fling(char, humanoid, humanoidRootPart)
local lookVector = humanoidRootPart.CFrame.LookVector
local upVector = humanoidRootPart.CFrame.UpVector
local timeFlinging = tick()
local flingDirection = lookVector * 100 + upVector * 100
humanoid.PlatformStand = true
local bv = Instance.new("BodyVelocity")
bv.Parent = humanoidRootPart
bv.P = 1750
bv.MaxForce = Vector3.new(9e9,9e9,9e9)
bv.Velocity = flingDirection
game.Debris:AddItem(bv,0.1)
local av = Instance.new("AngularVelocity")
av.Parent = humanoidRootPart
av.MaxTorque = 10000
av.ReactionTorqueEnabled = false
local att1 = attachmentCreater("att1", humanoidRootPart, CFrame.new(0,0,0))
local att2 = attachmentCreater("att2", humanoidRootPart, CFrame.new(0,0,0))
game.Debris:AddItem(att1,.1)
game.Debris:AddItem(att2,.1)
game.Debris:AddItem(av,.1)
av.Attachment0 = att1
av.Attachment1 = att2
av.AngularVelocity = Vector3.new(math.random(-20,20),math.random(-20,20),math.random(-20,20))
end
script.Parent.Fling.OnServerEvent:Connect(function(plr:Player)
local char = plr.Character
local hum = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")
fling(char,hum,hrp)
end)
also haven’t gotten to the point were you can stand back up after flinging but that should be simple enough to add on your own.
I whipped this up in ten minutes so It’s probably not the best.