Players jump animation in water part not working

The title says it all

local Sea = workspace:WaitForChild("Sea")

local RS = game:GetService("RunService")
local Character = script.Parent
local plr = game.Players.LocalPlayer
local Humanoid = Character:WaitForChild("Humanoid")
local Root = Character:WaitForChild("HumanoidRootPart")
local Swim

local function PlayersInPart(Part)
	local Parts = workspace:GetPartsInPart(Part)
	local Players = {}
	for i, v in pairs(Parts) do
		local Player = game.Players:GetPlayerFromCharacter(v.Parent)
		if v.Name == "LeftUpperArm" then
			if Player then
				table.insert(Players, Player)
			end
		end

	end
	return Players
end

RS.RenderStepped:Connect (function ()
	local PlayersInWater = PlayersInPart(Sea)
	if table.find(PlayersInWater, plr) then
		if Root.Position.Y < Sea.Position.Y - Root.Position.Y / 2 then
			if not Swim then
				Swim = Instance.new("BodyVelocity")
				Swim.Parent = Root
			end
			Humanoid.JumpPower = 30
			Humanoid.WalkSpeed = 16
			Swim.Velocity = Humanoid.MoveDirection * Humanoid.WalkSpeed
			if Humanoid:GetState() ~= Enum.HumanoidStateType.Swimming then
				Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
				Humanoid:ChangeState(Enum.HumanoidStateType.Swimming)
			end
		elseif Swim and Root.Position.Y < Sea.Position.Y then
			Swim.Velocity = Humanoid.MoveDirection * Humanoid.WalkSpeed
		elseif Swim then
			Swim:Destroy()
			Swim = nil
			Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
		end
	else
		if Swim ~= nil then
			Swim:Destroy()
			Swim = nil
			Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
		end

	end

end)
3 Likes

I might be wrong, but it looks like it’s working fine, but just playing over itself. You should make it start playing only once when the player starts to ascend, and then just loop the track (if it isn’t already looped) so that it’ll start and keep going til you stop it.

1 Like

yea I think ur right. Can you show it in an example? is this line supposed to be changed? Swim.Velocity = Humanoid.MoveDirection * Humanoid.WalkSpeed

1 Like

I’m not actually sure what’s causing the jump animation to play, but maybe if you wanted a more hacky solution, you could try reuploading the roblox jump animation and loading it as a track with higher priority, then just playing it yourself when the player’s swim direction is high enough on the Y axis.

If I had to guess what was actually playing the jump animation, maybe it’s because you’re pressing space and no other humanoid states are available that make more sense than jump?? I’m gonna be honest it’s beyond me, but you could try printing the humanoid state and see what it says when you ascend.

1 Like
  • Check for errors: Make sure that there are no errors being thrown in the output window when the player tries to jump in water.
  • Debug the code: Use print statements or breakpoints to check the values of variables and see if they are what you expect them to be. For example, you could check if the Humanoid.JumpPower property is being set correctly.
  • Check the animation: Make sure that the jump animation is properly set up and that it is being played when the player jumps.