Crouch floating when equip tool

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    To fix my crouch issue

  2. What is the issue? Include screenshots / videos if possible!
    My issue is that when i equip one of the tool
    while crouching it float me in air
    No matter which tool it keep floating me
    in air

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have try to make different crouch anim but nothing work

3 Likes

How does your crouch script currently look like by the way?

Also remember to use triple backsticks to make it easier for us to read and copy the script like so:

```lua
– Your code here, example:
print(true)
```

2 Likes
local Player = game:GetService("Players").LocalPlayer
local Values = Player:WaitForChild("Values")
local Character = script.Parent
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Remote = game:GetService("ReplicatedStorage"):WaitForChild("Remotes"):WaitForChild("CROUCH")
local Animations = script:WaitForChild("Animations")
local Crouch = false
local Walking = true
local PlayingWalk = false
local AnimationsTracks = {}

module.Crouch = function (self)
	Crouch = not Crouch

	if Crouch then
		AnimationsTracks["Idle"] = Humanoid:LoadAnimation(Animations:WaitForChild("Crouch"))

		AnimationsTracks["Idle"].Priority = Enum.AnimationPriority.Idle

		if AnimationsTracks["Idle"] then
			AnimationsTracks["Idle"]:Play()
			Remote:FireServer()
		end

		RunService.RenderStepped:Connect(function()
			if Crouch then
				local MoveDirection = Humanoid.MoveDirection

				if MoveDirection.Magnitude > 0 then
					Walking = true
				else
					Walking = false
				end
			end
		end)
	else
		if AnimationsTracks["Idle"] then
			AnimationsTracks["Idle"]:Stop()

			Remote:FireServer()
		end
	end
end

module.Init = function ()
	local self = setmetatable({},  {
		__index = module
	})

	UserInputService.InputBegan:Connect(function(Input, processed)
		if processed then
			return
		end
		
		if Input.KeyCode == Enum.KeyCode.C then
			self:Crouch()
		end
	end)

	return self
end

module.Init()
1 Like

Try setting the animation priority to something higher than Idle, like for example Action4

1 Like

nope still same bug i did it like u told me but nothing work

1 Like

Does your issue look like this:

If yes then I recommend trying out what chris_gaming489 wrote in the comments

2 Likes

To be honest with you my crouch script it do not connected to the gun system or animated it same way
I believe that it probably the script crouch issue for sure

2 Likes

You might need to create a new crouch animation for when the player is holding a Tool. Essentially you can use your existing crouch animation as a base, and make it so the character is also holding his hand up like they would do when holding a Tool

When a player equips a Tool you’ll need to stop the normal crouch animation and play the Tool crouch animation and do the opposite for when they unequip it

I understand but my gun system or crouch system is not connected to both
they are seperated script
how do u want me to do that

And how do i even do that cuz i dont have script for it

You’ll need to add a new function for your module that allows you to switch the currently playing animation, something like this should work:

local currentAnimation = -- The currently playing animation

module.Play = function (newAnimation)
	currentAnimation:Stop()
	currentAnimation = newAnimation
	currentAnimation:Play()
end

Where do u want me to add that script?

i can show u a screenshot
of my crouch system if u want

You can add it anywhere in the module really, but it must be before the module.Init() written at the bottom and after the local variables

hold on here

here all the screenshot of the script crouch
image

1 Like

I though you were using a ModuleScript not a LocalScript

Modules should be created inside of a ModuleScript in order to be able to use the functions inside of it from different scripts, otherwise you won’t be able to fix your crouching issue by changing the animation

so how can i fix please help dude

Have you uncolidicated and unAnchor all the parts inside those tools

No i never did but if u want me to do it to see if is fixed the bug then give me sec

UPDATE:
Nope it still same

It would be best if you learn how modules work first, I recommend reading this:

The reason why I’m saying this is because at this point I’ll otherwise have to remake your entire system to fix this problem which isn’t feasible

Im not really scripter is there another way??