[HELP!] - Attatch to HumanoidRootPart Script

Try to replace the default welds with weld constraints. Whats the primary part of hover?

I messed a little with that value and I didnā€™t see any differences

Try making it drastically different (like 5)

It is still happening the sameā€¦

Where are you setting this value?

I am setting the value to 5, like you told me. Now Iā€™m levitating by the way

No like how are you doing it (in code, during playtest etc)

In code or out of code itā€™s the same result

Not if the code doesnā€™t run. Show me the code.

Here is the code:

local EquipEvent = game.ReplicatedStorage.Events.VehicleEquip
local runser = game:GetService(ā€œRunServiceā€)

EquipEvent.OnServerEvent:Connect(function(player, hover)

local physicalplayer = game.Workspace:WaitForChild(player.Name)
print(hover.Name)
hover.Parent = physicalplayer

physicalplayer.Humanoid.HipHeight = 5

hover:SetPrimaryPartCFrame(physicalplayer.HumanoidRootPart.CFrame + Vector3.new(0,-2.4,0))

local weld = Instance.new("WeldConstraint",hover.PrimaryPart)
weld.Part0 = physicalplayer.HumanoidRootPart
weld.Part1 = hover.PrimaryPart

end)

local EquipEvent = game.ReplicatedStorage.Events.VehicleEquip
local runser = game:GetService(ā€œRunServiceā€)

EquipEvent.OnServerEvent:Connect(function(player, hover)

local physicalplayer = player.Character or player.CharacterAdded:Wait()
print(hover.Name)
hover.Parent = physicalplayer

physicalplayer:WaitForChild("Humanoid").HipHeight = 5

hover:SetPrimaryPartCFrame(physicalplayer.HumanoidRootPart.CFrame + Vector3.new(0,-2.4,0))

local weld = Instance.new("WeldConstraint",hover.PrimaryPart)
weld.Part0 = physicalplayer.HumanoidRootPart
weld.Part1 = hover.PrimaryPart

end)

Whoops forgot to put it in code. Try this.

Itā€™s happening the sameā€¦ I think the problem are the wheelsā€™ welds.

Ok so I had the idea to just make it an accessory instead, and here is the effect I achieved.

Is this what you are trying to do? If yes I can send you the file.

Edit: There are a couple of avatar restrictions though (The welded parts get wonky if the avatar size changes)

Yes, but while the wheels are moving

Wdym while the wheels are moving? Like you want an effect where the wheels move when the player moves?

Yes thatā€™s what this script does but itā€™s not finished yet

local player = game.Players.LocalPlayer
local hover = game.Workspace:WaitForChild(ā€œHOVER.ā€)
local EquipEvent = game.ReplicatedStorage.Events.VehicleEquip

local wheelspin = false
local directiontable = {}
local index

local runser = game:GetService(ā€œRunServiceā€)
local inputser = game:GetService(ā€œUserInputServiceā€)

local physicalplayer = game.Workspace:WaitForChild(player.Name)

EquipEvent:FireServer(hover)

inputser.InputBegan:Connect(function(input)

if input.KeyCode == Enum.KeyCode.W then
	table.insert(directiontable, "W")
	wheelspin = true
end

if input.KeyCode == Enum.KeyCode.A then
	table.insert(directiontable, "A")
	wheelspin = true
end

if input.KeyCode == Enum.KeyCode.S then
	table.insert(directiontable, "S")
	wheelspin = true
end

if input.KeyCode == Enum.KeyCode.D then
	table.insert(directiontable, "D")
	wheelspin = true
end

end)

inputser.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.W then
index = table.find(directiontable, ā€œWā€)
table.remove(directiontable, index)
end

if input.KeyCode == Enum.KeyCode.A then
	index = table.find(directiontable, "A")
	table.remove(directiontable, index)
end

if input.KeyCode == Enum.KeyCode.S then
	index = table.find(directiontable, "S")
	table.remove(directiontable, index)
end

if input.KeyCode == Enum.KeyCode.D then
	index = table.find(directiontable, "D")
	table.remove(directiontable, index)
end

if table.getn(directiontable) == 0 then
	wheelspin = false 
end

end)

while true do
while wheelspin == true do
for i, wheel in pairs(hover.Wheels:GetChildren()) do
wheel.CFrame = wheel.CFrame * CFrame.fromEulerAnglesXYZ(-0.27,0,0)
end
wait(0.025)
end
wait(0.2)
end

By the way you can just use Humanoid.StateChanged:Connect(function() instead of the tons of if statements in your uis events.

Edit: you can actually just use Humanoid.MoveDirection instead.

Dont know how but I managed to solve it, the code:

local ReplicatedStorage = game:GetService(ā€œReplicatedStorageā€)
local EquipEvent = ReplicatedStorage.Events.VehicleEquip

local runser = game:GetService(ā€œRunServiceā€)
local valuetable

EquipEvent.OnServerEvent:Connect(function(player, hover)
print(hover.Name)

local Wheel = ReplicatedStorage.Vehicles.Wheels:WaitForChild(hover.Name)
local Body = ReplicatedStorage.Vehicles.Bodies:WaitForChild(hover.Name):Clone()

local physicalplayer = player.Character or player.CharacterAdded:Wait()
Body.Parent = physicalplayer:WaitForChild("Vehicle")

local WheelPositions = Body:WaitForChild("WheelPositions")
local WheelSize = Body:WaitForChild("WheelSize")
print(WheelSize.Value)

if WheelPositions:FindFirstChild("RearLeftWheelPosition") and WheelPositions:FindFirstChild("RearRightWheelPosition") then
	valuetable = {"FrontRight", "FrontLeft", "RearRight", "RearLeft"}
	repeat
		local Wheelclone = Wheel:Clone()
		Wheelclone.Parent = physicalplayer:WaitForChild("Vehicle").Wheels
		Wheelclone.Name = valuetable[1].."Wheel"
		table.remove(valuetable, 1)
	until table.getn(valuetable) == 0

elseif WheelPositions:FindFirstChild("CenterWheelPosition") then

	valuetable = {"Right", "Left", "Center"}
	repeat
		local Wheelclone = Wheel:Clone()
		Wheelclone.Parent = physicalplayer:WaitForChild("Vehicle").Wheels
		Wheelclone.Name = valuetable[1].."Wheel"
		table.remove(valuetable, 1)
	until table.getn(valuetable) == 0

else

	valuetable = {"Right", "Left"}
	repeat
		local Wheelclone = Wheel:Clone()
		Wheelclone.Parent = physicalplayer:WaitForChild("Vehicle").Wheels
		Wheelclone.Name = valuetable[1].."Wheel"
		table.remove(valuetable, 1)
	until table.getn(valuetable) == 0

end

for i, wheel in pairs(physicalplayer.Vehicle.Wheels:GetChildren()) do
	
	local WheelPosition = WheelPositions:FindFirstChild(wheel.Name.."Position")
	print(WheelPosition)
	wheel.Position = Body.Position + WheelPosition.Value
	wheel.Size = WheelSize.Value
	
	local weld = Instance.new("WeldConstraint",wheel)
	weld.Part0 = wheel
	weld.Part1 = Body
	
end

physicalplayer.Vehicle.PrimaryPart = Body
physicalplayer.Vehicle:SetPrimaryPartCFrame(physicalplayer.HumanoidRootPart.CFrame + Vector3.new(0,-2.4,0))


local weld = Instance.new("WeldConstraint",Body)
weld.Part0 = physicalplayer.HumanoidRootPart
weld.Part1 = Body

end)

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