Thoughts on my absolutely horrendous glide script?

I know there’s a bug where you can gain “buildup” even when you’re faceramming the floor. I might fix that soon. Also, this is a LocalScript parented to the player’s character and that script has a NumberValue under it named BuildUp.
image

local uis = game:GetService("UserInputService")

local ws = 3
local ad = 3
local qe = 3

local wsadqe = {ws, ad, qe}
local plr = game.Players.LocalPlayer
local bv = Instance.new("BodyVelocity")
local hrp = plr.Character.HumanoidRootPart
bv.Parent = hrp
bv.MaxForce = Vector3.new(0, 0, 0)
bv.Velocity = Vector3.new(0, 0, 0)

task.wait()
local buildup = script.BuildUp --note: there is a NumberValue instance called "BuildUp" parented to this script

uis.InputBegan:Connect(function(key, chat)
	if chat then return end

	if key.KeyCode == Enum.KeyCode.LeftControl or key.KeyCode == Enum.KeyCode.RightControl then
		if bv.MaxForce == Vector3.new(0, 0, 0) then
			bv.MaxForce = Vector3.new(10000, 10000, 10000)
		else
			bv.MaxForce = Vector3.new(0, 0, 0)
			
			local params = RaycastParams.new()
			params.FilterType = Enum.RaycastFilterType.Exclude
			params.FilterDescendantsInstances = {plr.Character}
			
			local areyoutoonear = workspace:Raycast(hrp.Position, hrp.Position - Vector3.new(0, 500, 0))
			
			print(areyoutoonear.Distance)
			print(areyoutoonear.Instance)
			
			script.BuildUp.Value = plr.Character.PrimaryPart.Velocity.Magnitude
				
		end
	end

end)

while task.wait(1/40) do
	
	if bv.MaxForce ~= Vector3.new(0, 0, 0) then
		if plr:GetMouse().Hit.LookVector.Y > -0.025 or plr:GetMouse().Hit.LookVector.Y < -0.125 then
			buildup.Value -= plr:GetMouse().Hit.LookVector.Y / 4
		end
	else
		script.BuildUp.Value = plr.Character.PrimaryPart.Velocity.Magnitude
	end
	
	if buildup.Value > 0 then
		bv.Velocity = Vector3.new(plr:GetMouse().Hit.LookVector.X, plr:GetMouse().Hit.LookVector.Y * 0.75, plr:GetMouse().Hit.LookVector.Z) * buildup.Value
	else
		if plr:GetMouse().Hit.LookVector.Y > 0 then
			bv.Velocity = Vector3.new(0, buildup.Value, 0) --Vector3.new(0, plr:GetMouse().Hit.LookVector.Y, 0) * 10 * buildup.Value 
		end
	end
	
	if plr:GetMouse().Hit.LookVector.Y < 0 and buildup.Value < 0 then
		buildup.Value *= -1
	end
	
	buildup.Value = math.clamp(buildup.Value, -1000, 1000)
	
end
1 Like