Tweening the player is causing lots of problems

Hello!

I made a script in which I attempt to make a dash system. For it I create a part in front of the player and tween the player to the part. However it causes problems undescribable by words. I am tweening using the humanoid root part.

Here’s Code:

local plr = script.Parent.Parent.Parent
local char = plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")
local cam = game.Workspace.CurrentCamera
local debounce = false

local anim = hum:LoadAnimation(script.DashAnim)
local uis = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")

uis.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift and debounce == false then
		debounce = true
		
		local raycastParams = RaycastParams.new()
		raycastParams.FilterDescendantsInstances = {plr.Character}
		raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
		
		local raycastResult = game.Workspace:Raycast(hrp.Position, hrp.CFrame.LookVector * 35, raycastParams)
		
		if raycastResult then
			local hitPart = raycastResult.Instance
			print("Hit")
		else
			local info = TweenInfo.new(1)
			local DashGoal = Instance.new('Part')
			DashGoal.Parent = workspace
			DashGoal.Position = hrp.Position + Vector3.new(0, 0, -34)
			DashGoal.Transparency = 0.5
			DashGoal.Anchored = true
			DashGoal.CanCollide = false
			DashGoal.CastShadow = false
			
			hrp.Anchored = true
			local Dash = TweenService:Create(hrp, info, {Position = DashGoal.Position})
			Dash:Play()
			hrp.Anchored = false
		end
		
		wait(2)
		
		debounce = false
	end
end)

Here’s a video:

2 Likes

Do this on the client, and instead of setting the position, set the CFrame instead.

I am doing this on the client side and when I tried setting the CFrame it says I need to put in a vector3

Oops nevermind I am dumb xd you are right

1 Like

You need to do CFrame.new(DashGoal.Position) to use CFrame.