My fling is not working

I wanted to fling all the players in the game, but all the script does is puts the player in platformstand. I put the script in serverscriptservice which I am not sure about. The script goes:

local players = game.Players:GetPlayers()
for i,v in pairs(players) do
	v.Character.HumanoidRootPart.Velocity = Vector3.new(1500,1000,0)
	v.Character.Humanoid.PlatformStand = true
end

Hope you understood. I think the mistake is the parent of the script. Please help. Thanks!

Try changing this to :GetChildren()

That wouldn’t do anything, GetPlayers() for Players is the same as GetChildren() for an instance except it only returns Players

1 Like

The player will not move if they don’t have a network ownership of nil. You can easily prevent this if you create something like a BodyVelocity or a LinearVelocity to move the character.

Your fling script might break if someone is missing a character or a humanoidrootpart. Make sure you check to make sure they have one.

Example:

local Players = game.Players:GetPlayers()

for _, Player in pairs(Players) do
	local Character = Player.Character
	if not Character then
		continue
	end
	local Root = Character:FindFirstChild("HumanoidRootPart")
	local Humanoid = Character:FindFirstChildOfClass("Humanoid")
	if not Root or not Humanoid then
		continue
	end
	local BodyVelocity = Instance.new("BodyVelocity")
	BodyVelocity.Velocity = Vector3.new(1500, 1500, 0)
	BodyVelocity.MaxForce = Vector3.one * math.huge
	BodyVelocity.Parent = Root
	
	Humanoid.PlatformStand = true
end
1 Like

Oh could you please explain how it works?

Yes, I agree with what @samtheblender said. Try changing line 3 to: v.Character.HumanoidRootPart.BodyVelocity.Velocity = Vector3.new(1500,1000,0)

It works just great. I just need to play with it a bit because it flinged my character up in the skies. Anyway thanks for the help, appriciate it man.