How can I make this flying script work for R6 characters?

I’ve used this script for r15 characters but now I am using it for r6 characters but right now its broken. I tried to replace the PrimaryPart with the Head since it is the PrimaryPart but my character just glitches out the map when I start flying and when I stop flying teleports glitches into the ground. I haven’t found anything useful that would help me edit the script to make it suitable for r6 so any help would be appreciated with tweaking the code or finding a new system.

local player = game:GetService("Players").LocalPlayer

local character = player.Character or player.CharacterAdded:Wait()

local flyButton = script.Parent

local isFlying = false

local currentVelocity =, 0, 0)
local currentPosition = character:WaitForChild("PrimaryPart").Position

local function updatePosition()
	if isFlying then
		currentPosition = currentPosition + currentVelocity

local function toggleFly()
	if not isFlying then
		isFlying = true
		flyButton.Text = "Stop Flying"
		currentVelocity =, 50, 0)
		isFlying = false
		flyButton.Text = "Fly"
		currentVelocity =, 0, 0)
		character:SetPrimaryPartCFrame(, 0, character.PrimaryPart.Position.Z)))

local function onKeyPress(inputObject, gameProcessedEvent)
	if isFlying and not gameProcessedEvent then
		local newVelocity = currentVelocity
		if inputObject.KeyCode == Enum.KeyCode.W then
			newVelocity = newVelocity +, 0, -5)
		elseif inputObject.KeyCode == Enum.KeyCode.S then
			newVelocity = newVelocity +, 0, 5)
		elseif inputObject.KeyCode == Enum.KeyCode.A then
			newVelocity = newVelocity +, 0, 0)
		elseif inputObject.KeyCode == Enum.KeyCode.D then
			newVelocity = newVelocity +, 0, 0)
		currentVelocity = newVelocity




Are you sure you’ve used this script for R15 characters? Your initial velocity is 50 studs in the Y direction and the renderstepped function runs every 40th of a second so it shouldn’t matter if you are R15 or R6 you’d be going up 2000 studs per second. The reason you end up in the ground it because you are setting the Head to Position 0 when you stop flying. Trying setting it to like 5. This script will also be glitchy because your character is still always trying to fall to the ground due to gravity.

Are you getting an error when you run this code? You are doing WaitForChild(“PrimaryPart”) but PrimaryPart is a property not a child so you should be getting an infinite wait error here. Should just be character.PrimaryPart.Position.

You might want to search for some other flying scripts, I’m sure there are a couple that are a bit more functional.

I have made a major mistake that I have not realized and left out crucial pieces of code that I didn’t notice. I apologize for any inconvenience and I have fixed the issue.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.