Hi, I’m wondering how to replicate the client Motor6d to the server, I’ve tried dthecoolest solution, but it didn’t work.
Local script:
local figure = script.Parent
local torso = figure:WaitForChild("Torso")
local rightShoulder = torso:WaitForChild("Right Shoulder")
local leftShoulder = torso:WaitForChild("Left Shoulder")
local rightHip = torso:WaitForChild("Right Hip")
local leftHip = torso:WaitForChild("Left Hip")
local neck = torso:WaitForChild("Neck")
local humanoid = figure:WaitForChild("Humanoid")
local pose = "Standing"
local toolAnim = "None"
local toolAnimTime = 0
function onRunning(speed)
if speed > 0.01 then
pose = "Running"
else
pose = "Standing"
end
end
function onDied()
pose = "Dead"
end
function onJumping()
pose = "Jumping"
end
function onClimbing()
pose = "Climbing"
end
function onGettingUp()
pose = "GettingUp"
end
function onFreeFall()
pose = "FreeFall"
end
function onFallingDown()
pose = "FallingDown"
end
function onSeated()
pose = "Seated"
end
function moveJump()
rightShoulder.MaxVelocity = 0.5
leftShoulder.MaxVelocity = 0.5
rightShoulder.DesiredAngle = 3.14
leftShoulder.DesiredAngle = -3.14
rightHip.DesiredAngle = 0
leftHip.DesiredAngle = 0
end
function moveFreeFall()
rightShoulder.MaxVelocity = 0.5
leftShoulder.MaxVelocity = 0.5
rightShoulder.DesiredAngle = 3.14
leftShoulder.DesiredAngle = -3.14
rightHip.DesiredAngle = 0
leftHip.DesiredAngle = 0
end
function moveSit()
rightShoulder.MaxVelocity = 0.15
leftShoulder.MaxVelocity = 0.15
rightShoulder.DesiredAngle = 3.14 / 2
leftShoulder.DesiredAngle = -3.14 / 2
rightHip.DesiredAngle = 3.14 / 2
leftHip.DesiredAngle = -3.14 / 2
end
function getTool()
for _, v in ipairs(figure:GetChildren()) do
if v:IsA("Tool")then
return v
end
end
return nil
end
function getToolAnim(tool)
for _, v in ipairs(tool:GetChildren()) do
if v:IsA("Animation") then
return v
end
end
return nil
end
function animateTool()
if (toolAnim == "None") then
rightShoulder.DesiredAngle = 1.57
return
end
if (toolAnim == "Slash") then
rightShoulder.MaxVelocity = 0.5
rightShoulder.DesiredAngle = 0
return
end
if (toolAnim == "Lunge") then
rightShoulder.MaxVelocity = 0.5
leftShoulder.MaxVelocity = 0.5
rightHip.MaxVelocity = 0.5
leftHip.MaxVelocity = 0.5
rightShoulder.DesiredAngle = 1.57
leftShoulder.DesiredAngle = 1.0
rightHip.DesiredAngle = 1.57
leftHip.DesiredAngle = 1.0
return
end
end
function move(time)
local amplitude
local frequency
if (pose == "Jumping") then
moveJump()
return
end
if (pose == "FreeFall") then
moveFreeFall()
return
end
if (pose == "Seated") then
moveSit()
return
end
local climbFudge = 0
if (pose == "Running") then
rightShoulder.MaxVelocity = 0.15
leftShoulder.MaxVelocity = 0.15
amplitude = 1
frequency = 9
elseif (pose == "Climbing") then
rightShoulder.MaxVelocity = 0.5
leftShoulder.MaxVelocity = 0.5
amplitude = 1
frequency = 9
climbFudge = 3.14
else
amplitude = 0.1
frequency = 1
end
local desiredAngle = amplitude * math.sin(time * frequency)
rightShoulder.DesiredAngle = desiredAngle + climbFudge
leftShoulder.DesiredAngle = desiredAngle - climbFudge
rightHip.DesiredAngle = -desiredAngle
leftHip.DesiredAngle = -desiredAngle
local tool = getTool()
if tool then
local animStringValueObject = getToolAnim(tool)
if animStringValueObject then
toolAnim = animStringValueObject.Value
animStringValueObject.Parent = nil
toolAnimTime = time + .3
end
if time > toolAnimTime then
toolAnimTime = 0
toolAnim = "None"
end
animateTool()
else
toolAnim = "None"
toolAnimTime = 0
end
end
humanoid.Died:connect(onDied)
humanoid.Running:connect(onRunning)
humanoid.Jumping:connect(onJumping)
humanoid.Climbing:connect(onClimbing)
humanoid.GettingUp:connect(onGettingUp)
humanoid.FreeFalling:connect(onFreeFall)
humanoid.FallingDown:connect(onFallingDown)
humanoid.Seated:connect(onSeated)
local RunService = game:GetService("RunService")
local startTime = os.clock()
RunService.Stepped:Connect(function()
if figure.Parent ~= nil then
local deltaTime = os.clock() - startTime
move(deltaTime)
end
end)