Not printing any special movements

I am making a gun system and I am implementing shoot offset scaled by movement type for some reason it only prints “Standing shot” and “Walking shot”

My formatting is probably the problem but can someone help?

		if isMoving == false then
			if isCrouching.Value == false and isRunning.Value == false then
				print("Standing shot")
			elseif isCrouching.Value == true and isRunning.Value == false then
				print("Crouching shot")
			end
		elseif isMoving == true then
			if isCrouching.Value == false and isRunning.Value == false then
				print("Walking shot")
			elseif isCrouching.Value == true and isRunning.Value == false then
				print("Crouchwalking shot")
			elseif isCrouching.Value == false and isRunning.Value == true then			
				print("Sprinting shot")	
			end
		end

(Note: isRunning and isCrouching are both working fine)

For the case that isMoving is false, there is no reason to check isRunning since they are not moving. That’s my guess for “Crouching shot” not showing up.
For crouching, the logic can be simplified. Here’s my suggestion:

if isMoving then
	if isRunning.Value then
		print("Sprinting shot")	
	elseif isCrouching.Value then
		print("Crouchwalking shot")
	else
		print("Walking shot")
	end
else
	if isCrouching.Value then
		print("Crouching shot")
	else
		print("Standing shot")
	end
end

Note that I made the assumption that isRunning will not be true while you are crouching. Also I noticed, if “isMoving” is a value like the rest of the variables, you will need to check that with the Value property. I’m not sure if that was a typo, or it was just a boolean variable.

Both isCrouching and isRunning are boolean variables inside the character, whilst isMoving is a local variable that is set based of the humanoid’s magnitude.

Also, same result is happening for me.

So they are variables for true / false and not references to Value instances? In that vase, we don’t need to be using the Value property at all.

1 Like

Removed the .Values and now standing shots are crouching shots and walking shots are sprinting shots

Try printing isCrouching’s value to see if it is even being set. If not, it could be an issue with detecting the user’s input (which I’m assuming you’re using to crouch).

Weird. When I check the character, isCrouching is true but it prints out false

EDIT: Crouch and sprint handler is in a local script and gun handler is in a server script, could this have an effect?

It could, but it depends. I believe values replicate from server to client, but if you’re changing the values on the client and checking them on the server, that won’t work.

So I guess thats the problem.

Do you think calculating the spread on my gun client script and sending them over would be smart?

I think sending over the raw values to the server and calculating them there would make them less exploitable, but either way would work fine. Just use a remote.