Fling Command Doesn't work?

I’ve made chat commands and I recently added a new command: “J:Fling”. This command is supposed to fling the Target’s HRP using body forces, for a split second or so before destroying the instance, to create the fling affect. However, when I try to implement this, it doesn’t work. Any reason why?

SS Code:

	elseif Command == "J:Fling" then
				print("Flinging...")
				local Target = ArgsTable[2]
				if Target == "all" then
					for indexPlayer, Player in pairs(game.Players:GetPlayers()) do
						local Character = Player.Character
						if Character then
							local HRP = Character:WaitForChild("HumanoidRootPart")
							local BodyForce = Instance.new("BodyForce")
							BodyForce.Force = Vector3.new(0, 9999999, 0)
							BodyForce.Parent = HRP
							delay(.5, function()
								BodyForce:Destroy()
							end)
						end
					end
				else
					local Found_Player = MainModule.FindClosestMatchString("PlayerSearch", game.Players:GetPlayers(), Target)
					if Found_Player then
						local Character = Found_Player.Character
						if Character then
							local HRP = Character:WaitForChild("HumanoidRootPart")
							local BodyForce = Instance.new("BodyForce")
							BodyForce.Force = Vector3.new(0, 99999, 0)
							BodyForce.Parent = HRP
							delay(.5, function()
								BodyForce:Destroy()
							end)
						end
					end
				end

I know the module functions work, as I use them for other commands, I’d really appreciate an explanation as to why it won’t fling. Thanks!

:smile:

1 Like

Do you experience any errors? if so what and which line.

no errors, only the flinging… output from the chatchandler script

Have you tried print debugging? Also, have you considered using DebrisService to remove the BodyForce once the fling is over?

I did try using it, but i was unsuccessful. Let me have another attempt, and I’ll post the code here.

EDIT: Using debris service didn’t fix the problem, but I think its the fact that when I do this:

					local Found_Player = MainModule.FindClosestMatchString("PlayerSearch", game.Players:GetPlayers(), Target)
					if Found_Player then
						local Character = Found_Player.Character
						if Character then
							local HRP = Character:WaitForChild("HumanoidRootPart")
							local BodyForce = Instance.new("BodyForce")
							BodyForce.Force = Vector3.new(0, math.huge, 0) --changed to math.huge
							BodyForce.Parent = HRP
							delay(.5, function()
								BodyForce:Destroy()
							end)

It does fling me, resulting in me dying.
I think, I’d be off using BodyVelocity instead, as the bdoy force applies a constant force, and not a natural fling, which slows down after time