How to fling a player?


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…

5 Likes

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.

is it possible if you can help me with my issue?

No, I have never worked with ChatService I have no clue how it works or what issues it causes with other things.

1 Like

It would be the best if the result comes as close as the one in the video, optionally. How would I use the “apply impulse system”?

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

this my first post xd

Im booting back up studio to try this…

One way could be to spawn a part inside the character’s torso

I did this and now the player is just having a seizure

1 Like

This actually looks quite good! Only the sitting position left and maybe a break up after 1 second will help and physics will do the rest?

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.

This looks INSANE! How did you do this?

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)

If you want the full flinging code here it is.

Client:

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.

3 Likes

This is literally SO perfect! It works so well! Thank you so much! Ive tried seating the player with humanoid.sitting = true, but it didn’t work :frowning:

Its Sit not sitting also do it after the platformstand otherwise i think the player might have enough time to press space to stand back up

also, the attachment creators, wouldn’t it be logical to delete those attachments afterwards?

it is Game.Debris:AddItem() will create the item and delete after the specified second value so it would go like this Game.Debris:AddItem(item, time)

Ooh, didn’t know what debris stood for yet, thanks for the clarification! I will mark this as the solution, thank you so much!

1 Like