How to make the player not float when driving hoverboard

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

Before I scripted the movement the player wasn’t floating but now it is. I want to make sure the player isn’t floating when their driving the hoverboard

  1. What is the issue? Include screenshots / videos if possible!

The player floats and I want it not to.
image

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I have tried changing the C0 for the weld but the player is still floating. I have searched up and found nothing about how to fix it.

-- Server Script
local ProximityPromptService = game:GetService("ProximityPromptService")

local Prompt = script.Parent.Parent.ProximityPrompt
local Hoverboard = script.Parent.Parent
-- Values
local currentHumanoid = nil
local currentAnim = nil

local bp = Instance.new("BodyPosition")
bp.D = 1000
bp.MaxForce = Vector3.new(0, 0, 0)
bp.Parent = script.Parent.Parent

local bg = Instance.new("BodyGyro")
bg.MaxTorque = Vector3.new(0, 0, 0)
bg.Parent = script.Parent.Parent

script.Parent.Parent.BackParticles.ParticleEmitter.Enabled = false
script.Parent.Parent.FrontParticles.ParticleEmitter.Enabled = false

Prompt.PromptButtonHoldEnded:Connect(function(player)
	local Character = player.Character
	local Humanoid = Character.Humanoid
	
	if Humanoid.Health > 0 then
		script.Parent.Parent:SetNetworkOwner(player)
		
		Prompt.Enabled = false
		currentHumanoid = Humanoid
		
		Humanoid.WalkSpeed = 0
		
		local weld = Instance.new("Weld", script.Parent.Parent)
		weld.Name = "PlayerWeld"
		weld.Part0 = script.Parent.Parent
		weld.Part1 = Character.HumanoidRootPart

		weld.C0 = CFrame.new(0, (Character.HumanoidRootPart.Size.Y * 0.5) + Character.Humanoid.HipHeight, 0)
		
		game.ReplicatedStorage.ActivateHoverboard:FireClient(player, script.Parent.Parent)

		bp.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
		bg.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
		
		local Animator = currentHumanoid:FindFirstChild("Animator")

		if Animator then
			currentAnim = Animator:LoadAnimation(Hoverboard.sitanim)
			currentAnim:Play()
		end
		
		script.Parent.Parent.BackParticles.ParticleEmitter.Enabled = true
		script.Parent.Parent.FrontParticles.ParticleEmitter.Enabled = true
	end
end)

-- Client Script
-- Services
local UIS = game:GetService("UserInputService")

local player = game.Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local HRP = Character.HumanoidRootPart

local ActivateHoverboard = game.ReplicatedStorage:WaitForChild("ActivateHoverboard")

local currentHoverboard = nil

local movement = Vector3.new()
local rotation = 0
local movementSpeed = 10

ActivateHoverboard.OnClientEvent:Connect(function(hb)
	print(hb)
	currentHoverboard = hb
end)

UIS.InputEnded:Connect(function(input)
	if UIS:GetFocusedTextBox() == nil then
		print(2)
		-- If they want to exit the hoverboard
		if input.KeyCode == Enum.KeyCode.F then
			currentHoverboard = nil
			movement = Vector3.new()
			rotation = 0
			return
		end

		-- Movement
		if input.KeyCode == Enum.KeyCode.W then
			print(1)
			movement = Vector2.new(movement.X, 1 * movementSpeed)
		elseif input.KeyCode == Enum.KeyCode.A then
			print(2)
			movement = Vector2.new(-1, movement.Y * movementSpeed)
			rotation = 20
		elseif input.KeyCode == Enum.KeyCode.S then
			print(3)
			movement = Vector2.new(movement.X, -1 * movementSpeed)
		elseif input.KeyCode == Enum.KeyCode.D then
			print(4)
			movement = Vector2.new(1, movement.Y * movementSpeed)
			rotation = -20
		end
	end
end)


game:GetService("RunService").Heartbeat:Connect(function()
	if currentHoverboard ~= nil then
		if movement then
			local rayOrigin = currentHoverboard.Position
			local rayDirection = -currentHoverboard.CFrame.UpVector * 1000
			
			local raycastParams = RaycastParams.new()
			raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
			raycastParams.FilterDescendantsInstances = {currentHoverboard}
			
			local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
			
			if raycastResult then
				local groundY = raycastResult.Instance.Position.Y + (raycastResult.Instance.Size.Y / 2)
				
				currentHoverboard.BodyPosition.Position = Vector3.new(currentHoverboard.Position.X, groundY + 1.5, currentHoverboard.Position.Z)
				currentHoverboard.BodyGyro.CFrame = currentHoverboard.CFrame * CFrame.Angles(0, rotation, 0)
				HRP.Velocity = Vector3.new()
				currentHoverboard.PlayerWeld.C0 = CFrame.new(0, (Character.HumanoidRootPart.Size.Y * 0.5) + Character.Humanoid.HipHeight * (groundY + 1), 0)
			end
		end
	end
end)

Thanks for trying to help me fix this issue!

2 Likes

I think that you would have to change the C1 in order to fix it, considering the fact that the Part1 of the Motor6D instance is the character itself, as it is looking here:

weld.Part1 = Character.HumanoidRootPart
2 Likes

I have a question. What would C1 equal?

2 Likes

C1 is quoting:
Is subtracted from the JointInstance.C0 property to create an offset point for JointInstance.Part1.
I would assume mess around with the UpVector values:

Motor6D.C1 = CFrame.new(0, ..., 0) -->> Test out some values in the ... (the UpVector).
3 Likes

I can only get this far.
image

Then you can try to do the same thing for the C0 value as well, mess with the UpVector values until it fits.

Also do you know how to do this? How to make a hoverboard movement - Help and Feedback / Scripting Support - DevForum | Roblox

I won’t be able to respond further, but my approach would be to use BodyPosition and BodyGyro and constantly update the position and rotation based on the User Input.

I am using BodyPosition and BodyGyro but I don’t know what to do.

I have figured out how to make it stand. I used a seat to do so! Thanks for all the help