My HumanoidRootPart can’t move with Vector3.
How can i make HumanoidRootPart move?
local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character
local UIS = game:GetService("UserInputService")
local tweenService = game:GetService("TweenService")
local humanoid = Character:WaitForChild("Humanoid")
local humanoidrp = Character:WaitForChild("HumanoidRootPart")
local ti = TweenInfo.new(
0.5,
Enum.EasingStyle.Sine
)
UIS.InputBegan:connect(function(input)--When a player has pressed LeftShift it will play the animation and it will set the normal walking speed (16) to 35.
if input.KeyCode == Enum.KeyCode.E then
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://16488920677'
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
PlayAnim:Play()
tweenService:Create(humanoid, ti, {CFrame = humanoidrp.CFrame + Vector3.new(5, 0, 0)}):Play()
end
end)
UIS.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
PlayAnim:Stop()
end
end)
You can actually add a Vector3 onto a CFrame but not the other way around.
This works: CFrame + Vector3 = CFrame
This doesn’t work; Vector3 + CFrame
They’re tweening the ‘humanoid’ and not the humanoid root part: tweenService:Create(humanoid, ti, {CFrame = humanoidrp.CFrame + Vector3.new(5, 0, 0)}):Play()
Atm you have it set to one direction, so if you wanted to have it go in left/right relative to the root part then use the root part’s cframe to your advantage.
Like:
local direction = rootPart.CFrame.RightVector
local distance = 5
-- // left is -direction || forward is lookvector || backwards is -lookvector
tweenService:Create(rootPart, ti, {CFrame = rootPart.CFrame + direction * distance}):Play()