When i try to jump on my hoverboard, instead of going up and down, it just ramps the speed up, and never stops. Here is an video of it.
Also here is my script:
local RunService = game:GetService("RunService")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local connection = nil
local seat = nil
local attachment = nil
local vectorForce = nil
local orientation = nil
local alignOrientation = nil
local raycastParams = nil
local rayOffset = Vector3.new(0, -8, 0)
local thrust = 2000
local animationTrack = humanoid:WaitForChild("Animator"):LoadAnimation(script:WaitForChild("Animation"))
animationTrack.Priority = Enum.AnimationPriority.Idle
local rayPart = Instance.new("Part")
rayPart.Anchored = true
rayPart.CanCollide = false
rayPart.CanQuery = false
rayPart.CanTouch = false
rayPart.Shape = Enum.PartType.Ball
rayPart.Size = Vector3.one
rayPart.Parent = workspace
local function Loop(deltaTime)
local rayTarget = seat.Position * rayOffset
local result = workspace:Raycast(seat.Position, rayTarget - seat.Position, raycastParams)
if result == nil then
vectorForce.Force = Vector3.zero
rayPart.BrickColor = BrickColor.Green()
rayPart.Position = rayTarget
print("hello")
else
local magnitude = (result.Position - rayTarget).Magnitude
vectorForce.Force = Vector3.new(0, magnitude * thrust, 0)
rayPart.BrickColor = BrickColor.Red()
rayPart.Position = result.Position
end
end
local function Seated(active, currentSeat)
if active == false then
if connection == nil then return end
connection:Disconnect()
connection = nil
attachment:Destroy()
vectorForce:Destroy()
alignOrientation:Destroy()
animationTrack:Stop()
elseif currentSeat.Name == "Hoverboard" then
seat = currentSeat
attachment = Instance.new("Attachment", seat)
vectorForce = Instance.new("VectorForce")
vectorForce.Force = Vector3.zero
vectorForce.ApplyAtCenterOfMass = true
vectorForce.Attachment0 = attachment
vectorForce.Parent = seat
orientation = CFrame.fromMatrix(Vector3.zero, seat.CFrame.LookVector:Cross(Vector3.yAxis), Vector3.yAxis)
alignOrientation = Instance.new("AlignOrientation")
alignOrientation.Mode = Enum.OrientationAlignmentMode.OneAttachment
alignOrientation.CFrame = orientation
alignOrientation.Attachment0 = attachment
alignOrientation.Parent = seat
raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.FilterDescendantsInstances = {character, seat:FindFirstAncestorOfClass("Model")}
connection = RunService.PostSimulation:Connect(Loop)
animationTrack:Play()
end
end
humanoid.Seated:Connect(Seated)