Hi,
I am trying to code a new animation of a forward roll, the issue I am facing is getting the root part in the correct place is it does not move with the animation.
I am moving the camera with the player’s head and moving the root to the upper torso but the player ends up in the floor.
I have tried moving the Y position but this does not appear to help.
Am I doing this correctly or is there another way? I have made the root visible so I can see what its doing.
local UIS = game:GetService("UserInputService")
local char = script.Parent
local hum = char:WaitForChild("Humanoid")
local head = char:WaitForChild("Head")
local root = char:WaitForChild("HumanoidRootPart")
root.Transparency = 0
local torso = char:WaitForChild("UpperTorso")
local animPlay = hum:LoadAnimation(script:WaitForChild("Animation"))
local canCrawl = false
animPlay:AdjustSpeed(0)
hum.Running:Connect(function(speed)
if speed > 0 then
animPlay:AdjustSpeed(1)
else
animPlay:AdjustSpeed(0)
end
end)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.R then
if not canCrawl then
canCrawl = true
hum.HipHeight = 3
hum.WalkSpeed = 4
hum.JumpPower = 0
--if hum.MoveDirection.Magnitude > 0 then
animPlay:Play()
--end
game.Workspace.CurrentCamera.CameraSubject = head
animPlay.Stopped:Wait()
root.Position = Vector3.new(torso.Position.X, torso.Position.Y, torso.Position.Z)
else
canCrawl = false
hum.HipHeight = 3
hum.WalkSpeed = 16
hum.JumpPower = 50
animPlay:Stop()
end
end
end)