Moving changes cframe offset

I want the part to stay a constant distance from the player when made even when moving

I’ve tried using Run service to update the part when the player is moving but it looks weird and will not translate well when working with other scripts.
I also tried to anchor the HRP which bugs other scripts

Client

	if input.KeyCode == Enum.KeyCode.E and Debounce == false then
		if WalkAnim.IsPlaying == true then
			WalkAnim:Stop(.1)
		end
		Debounce = true
		
		Humanoid.WalkSpeed = 0
		Humanoid.JumpPower = 0
		task.wait(0.001)
		Remotes.Character.Noelle.NoelleONE:FireServer(Player, Mouse.Hit.Position)
		task.wait(1)
		Humanoid.WalkSpeed = WS
		Humanoid.JumpPower = JP
		task.wait(4)
		Debounce = false
		
	end	

Server

NoelleRemote.OnServerEvent:Connect(function(player)
	local function Soundplay(Sound, MainParent)
		if MainParent == nil then
			MainParent = player.Character.HumanoidRootPart
		end
		local Soundeffect = Sound:Clone()
		Soundeffect.Parent = MainParent
		Soundeffect:Play()
		game.Debris:AddItem(Soundeffect, Soundeffect.TimeLength)
	end	
	
	Hitbox = Instance.new("Part")
	Hitbox.Parent = game.Workspace.FxHolder
	Hitbox.Size = Vector3.new(2.8, 5.17, 1.98)
	Hitbox.Anchored = true
	Hitbox.CanCollide = false
	Hitbox.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-3)
	
	
	
end)

Are you moving the part on the server or the client?

If it’s on the server then expect some jittery behaviour, but if its on the client, make sure you’re using RunService.RenderStepped.

You can’t perfectly move the part in-speed with the player on the server, as what server sees is not what the client sees because of latency.

1 Like

Your issue is the part is anchored, so it stays in world space after being created.
Instead of updating it every frame with RunService.

May be best to just weld it to the player..
What is going wrong with this?

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local HRP = character:WaitForChild("HumanoidRootPart")task.wait(1)

local Hitbox = Instance.new("Part")
Hitbox.Parent = workspace
Hitbox.Size = Vector3.new(2.8, 5.17, 1.98)
Hitbox.CanCollide = false
Hitbox.Anchored = false
Hitbox.Massless = true

local weld = Instance.new("Weld")
weld.Part0 = HRP
weld.Part1 = Hitbox
weld.C0 = CFrame.new(0, 0, -3)
weld.Parent = Hitbox

Thank you for this information I’ll keep that in mind.

This works but it kind of moves the character a little and flings them
(I added cframe because it kept putting the player at the world orign)

NoelleRemote.OnServerEvent:Connect(function(player)
	local Weld = Instance.new("Motor6D")
	
	local HRP = player.Character:WaitForChild("HumanoidRootPart")task.wait()
	
	Hitbox = Instance.new("Part")
	Hitbox.Parent = game.Workspace.FxHolder
	Hitbox.Anchored = false
	
	Hitbox.Size = Vector3.new(2.8, 5.17, 1.98)
	Hitbox.Color = Color3.new(255, 0, 0)
	Hitbox.Transparency = 0.5
	

	Hitbox.CanCollide = false
	Hitbox.CFrame = HRP.CFrame
	
	Weld.Part0 = HRP
	Weld.Part1 = Hitbox
	Weld.C0 = CFrame.new(0,1,-3)
	Weld.Parent = Hitbox
	
	game.Debris:AddItem(Hitbox, 1)
	
end)
1 Like

Odd, I even watched for that..

Turn on massless property for the hitbox to fix it.