So I’m currently working on getting a sorta realistic animation script working. I’ve gotten to the point that it works pretty well but I got this weird bug and I honestly don’t really understand how exactly “:AdjustWeight” works.
Heres the bug ^^^ basically what happens is that the script works fine but as soon as I switch from serverside view to clientside view the script breaks entirely. Theirs no error messages which really confuses me. Heres my script, please tell me if I’m using AnimationWeight correctly?
local character=script.Parent
local humanoid=character:WaitForChild("Humanoid")
local jointR=character:WaitForChild("HumanoidRootPart"):WaitForChild("RootJoint")
local originR=jointR.C1
local agility=16
local UIS=game:GetService("UserInputService")
script:WaitForChild("Movement"):WaitForChild("walkA0")
local currently_playing_anim={}
local anim={
["frontwalk"]=humanoid:LoadAnimation(script.Movement.walkA0.Animation);
["rightwalk"]=humanoid:LoadAnimation(script.Movement.walkA1.Animation);
["leftwalk"]=humanoid:LoadAnimation(script.Movement.walkA2.Animation);
["backwalk"]=humanoid:LoadAnimation(script.Movement.walkA3.Animation)
}
local X,Z = 0,0
for i,v in pairs(anim) do
v:Play()
v.Looped=true
end
local function setallweight(num)
for i,v in pairs(anim) do
v:AdjustWeight(num)
end
end
humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
anim["backwalk"]:AdjustSpeed(humanoid.WalkSpeed/10)
anim["frontwalk"]:AdjustSpeed(humanoid.WalkSpeed/10)
end)
game:GetService("RunService").RenderStepped:Connect(function()
local movedir=character.PrimaryPart.CFrame:vectorToObjectSpace(humanoid.MoveDirection)
local currentstate=humanoid:GetState()
X=movedir.X--math.floor(X+0.5)
Z=movedir.Z--math.floor(Y+0.5)
if currentstate==Enum.HumanoidStateType.Jumping then
setallweight(0)
elseif currentstate==Enum.HumanoidStateType.Freefall then
setallweight(0)
else
jointR.C1=jointR.C1:lerp(originR*CFrame.Angles(math.rad(Z*15),math.rad(X*15),0),0.05)
if Z~=0 then
anim["frontwalk"]:AdjustWeight(math.max(Z*-1,0))
anim["backwalk"]:AdjustWeight(math.max(Z,0))
else
anim["frontwalk"]:AdjustWeight(0)
anim["backwalk"]:AdjustWeight(0)
end
if X~=0 then
anim["rightwalk"]:AdjustWeight(math.max(X*-1,0))
anim["leftwalk"]:AdjustWeight(math.max(X,0))
else
anim["rightwalk"]:AdjustWeight(0)
anim["leftwalk"]:AdjustWeight(0)
end
end
end)