Landing animation playing on every player?

I have an animation which plays when the player lands, I use the roblox sound script since it already has it made.

Heres an example of what I mean for the bug:

So you can see whenever the other players land, it also makes me play the landing animation. Heres the script:

local plr = Players.LocalPlayer
local chr
repeat task.wait()
chr = plr.Character;
until chr ~= nil
local hum = chr:WaitForChild("Humanoid")
local hroot = chr:WaitForChild("HumanoidRootPart")
local Values = chr:WaitForChild("Values")

local Animation = Instance.new("Animation")
Animation.AnimationId = 'rbxassetid://16078098843'
local Animator = hum:FindFirstChildWhichIsA("Animator")
local LandAnim = Animator:LoadAnimation(Animation)

--Skip to landing part

[Enum.HumanoidStateType.Landed] = function()
			stopPlayingLoopedSounds()
			
			chr["Left Arm"].LeftArmTrail.Enabled = false
			chr["Right Arm"].RightArmTrail.Enabled = false
			chr["Left Leg"].LeftLegTrail.Enabled = false
			chr["Right Leg"].RightLegTrail.Enabled = false
			
			local verticalSpeed = math.abs(rootPart.AssemblyLinearVelocity.Y)
			if verticalSpeed > 75 then
				sounds.Landing.Volume = math.clamp(map(verticalSpeed, 50, 100, 0, 1), 0, 1)
				playSound(sounds.Landing)
				hum.JumpPower = 0
				hum.WalkSpeed = Values.Movement.WalkSpeed.Value / 4
				LandAnim:Play()  --LANDING ANIMATION PLAYS HERE
				
				local list = {}
				for _, v in pairs(game:GetService("Players"):GetPlayers()) do
					for _, q in pairs(v.Character:GetDescendants()) do
						table.insert(list, q)
					end
				end

				local raycastParams = RaycastParams.new()
				raycastParams.FilterDescendantsInstances = list
				raycastParams.FilterType = Enum.RaycastFilterType.Exclude

				local raycastResult = workspace:Raycast(hroot.Position, Vector3.new(0, -10, 0), raycastParams)
				if raycastResult ~= nil then
					local hitPart = raycastResult.Instance
					hroot.LandEffect.ParticleEmitter.Color = ColorSequence.new{
						ColorSequenceKeypoint.new(0, Color3.fromRGB(50, 50, 50)),
						ColorSequenceKeypoint.new(.25, (hitPart.Color)),
						ColorSequenceKeypoint.new(1, (hitPart.Color))
					}
				else
					hroot.LandEffect.ParticleEmitter.Color = ColorSequence.new{
						ColorSequenceKeypoint.new(0, Color3.fromRGB(50, 50, 50)),
						ColorSequenceKeypoint.new(.25, Color3.fromRGB(150, 150, 150)),
						ColorSequenceKeypoint.new(1, Color3.fromRGB(150, 150, 150))
					}
				end
				hroot.LandEffect.ParticleEmitter:Emit(10)
				
				task.delay(.15, function()
					hum.WalkSpeed = Values.Movement.WalkSpeed.Value
					hum.JumpPower = Values.Movement.JumpPower.Value
				end)
			end
		end,
2 Likes

When does [Enum.HumanoidStateType.Landed] = function() actually fire? If you add a print statement to the start of it, does it happen only once or every time that any player lands?

What’s the code that handles calling the landed function?

2 Likes

Its the RbxCharacterSounds script. The point in which the landed sound plays I added the animation for landing aswell

1 Like

Try not using the character sounds script, instead connecting the function up to game.Players.LocalPlayer.Humanoid.StateChanged:Connect…, and checking if the state is landed

2 Likes

So just move the landed function into a separate script?

2 Likes

Yeah, it can’t hurt to try

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.