Hello! Im trying to make a animation and sound script in my game so I can have custom animations and custom sounds for my custom character.
Im getting no errors and my script is not working! How can I fix this?
My Script is located in StarterCharacterScripts
Script
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local idleAnim = Instance.new("Animation")
idleAnim.AnimationId = "rbxassetid://7208722455"
local idleAnimTrack = humanoid.Animator:LoadAnimation(idleAnim)
local runAnim = Instance.new("Animation")
runAnim.AnimationId = "rbxassetid://7208894477"
local runAnimTrack = humanoid.Animator:LoadAnimation(runAnim)
local JumpSound = Instance.new("Sound")
JumpSound.SoundId = "rbxassetid://8396408200"
JumpSound.Parent = humanoid.Parent:WaitForChild("Torso")
JumpSound.Volume = 10
humanoid.Running:Connect(function(speed)
if speed == 0 then
idleAnimTrack:Play()
else
if speed > 0 then
runAnimTrack:Play()
else
runAnimTrack:Stop()
end
end
end)
if humanoid.Jump == true then
JumpSound:Play()
end
It seems that jump-sound has only been set to play, at the startup of your script and does not have a connection to the humanoid, unlike how your running does.
Other than that, I can not see anything that regards a script error [That is script related].
EDIT: Also, I advise running idle at startup instead, If the animation was set up accordingly then unless you use the stop function it will always run in the background. [That is if the animation is set to loop]