Checking for Attributes not working

I wanted to check for attributes on my run script and some other scripts so I can’t run whenever I’m ragdolled or stunned. I tried it out in the local script it did nothing so then I tried it out in a module script and it broke my script.

The Run script is below

-- Services
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local Player = game:GetService("Players")

-- Tick and Player
local lastTime = tick()
local player = game.Players.LocalPlayer

-- Humanoid and Run Vari's
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local run = false
local IsCrouching = false
local Track1 

-- Folders 

-- Varis and Functions 
local WKey = Enum.KeyCode.W
local SKey = Enum.KeyCode.S
local SKeyHeld = false

-- Modules
local MISCModule = require(RS.Storage.Modules.MISC.Misc)

-- Atributes
local currentWeapon = char:GetAttribute("CurrentWeapon")
local IsBlocking = char:GetAttribute("IsBlocking")
local attacking = char:GetAttribute("Attacking")
local stunned = char:GetAttribute("Stunned")
local IsRagdoll = char:GetAttribute("IsRagdoll")
local IsRunning = char:GetAttribute("IsRunning")

-- Setting IsRunning
Player.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char:SetAttribute("IsRunning", false)
		end)
	end)

-- Bugs
UIS.InputBegan:Connect(function(input, GPE)
	if not GPE then
		if input.KeyCode == Enum.KeyCode.LeftControl then
			IsCrouching = true
		end
	end
end)

UIS.InputEnded:Connect(function(input, GPE)
	if input.KeyCode == Enum.KeyCode.LeftControl  then
		if not GPE then
			IsCrouching = false
		end
	end
end)

UIS.InputBegan:Connect(function(input, GPE)
	if not GPE then
		if input.KeyCode == Enum.KeyCode.LeftControl and run == true then
			
			run = false
			char:SetAttribute("IsRunning", false)
			if Track1 then 
				Track1.Priority = Enum.AnimationPriority.Movement
				Track1:Stop(0.300000001)
			end
			hum.WalkSpeed = 8
			IsCrouching = true
			if IsBlocking then 
				hum.WalkSpeed = 4
			end
		end
	end
end)

UIS.InputEnded:Connect(function(input, GPE)
	if not GPE then
		if input.KeyCode == Enum.KeyCode.LeftControl and run == true then
			run = false
			char:SetAttribute("IsRunning", false)
			if Track1 then 
				Track1.Priority = Enum.AnimationPriority.Movement
				Track1:Stop(0.300000001)
			end
			hum.WalkSpeed = 8
			IsCrouching = false
			
		end
	end
end)


-- Main Scripting
local Running = game.StarterPlayer.StarterCharacterScripts.Runs.Value
local runs = char:WaitForChild("Running")
UIS.InputBegan:Connect(function(input,GPE)
	if input.KeyCode == Enum.KeyCode.W then
		if GPE then return end
		print ("Checking for attributes")
		if MISCModule.CheckForAttributes(char, true, true, true,_G, true) then return end
		print ("Check passed")
		if char:FindFirstChild("Ragdoll") then return end
		local now = tick()
		local difference = (now - lastTime)
		-- 0.5 seconds till you can press w so you can start running.
		if difference <= 0.5 and IsCrouching == false and SKeyHeld == false then
			print (IsBlocking)
	
			run = true
			char:SetAttribute("IsRunning", true)
			print (IsRunning)
				
				Track1 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Run)
			
			
			Track1.Priority = Enum.AnimationPriority.Movement	
			Track1:Play(0.500000001)
			wait (0.1)
			
			
				hum.WalkSpeed = 24.5
			runs.Value = true
			end
		lastTime = tick()
	end
end)

-- Bug Fixing 
UIS.InputBegan:Connect(function(input,gameprocessed)
	if gameprocessed then return end
	-- If you press S while running 
	if input.KeyCode == Enum.KeyCode.S then 
		SKeyHeld = true
		run = false
		char:SetAttribute("IsRunning", false)
		if IsCrouching == true then
			hum.WalkSpeed = 8
		elseif IsCrouching == false and Track1 then
			hum.WalkSpeed = 16 
		end
		if IsBlocking then 
			hum.WalkSpeed = 4
		end
		
		
		if Track1 then 
			Track1.Priority = Enum.AnimationPriority.Movement
			Track1:Stop(0.300000001)
		end
		
		runs.Value = false
		return
	end
	
end)

UIS.InputEnded:Connect(function(input,gameprocessed)
	if gameprocessed then return end
	-- If you press S and hold it then press W twice
	if input.KeyCode == Enum.KeyCode.S  then
		SKeyHeld = false
		run = false
		char:SetAttribute("IsRunning", false)
		if Track1 then
			Track1.Priority = Enum.AnimationPriority.Movement
			Track1:Stop(0.300000001)
		end
		if IsCrouching == true then
			hum.WalkSpeed = 8
		elseif IsCrouching == false and Track1 then
			hum.WalkSpeed = 16 
		end
		
		if IsBlocking then 
			hum.WalkSpeed = 4
		end
		runs.Value = false
	end
end)

UIS.InputBegan:Connect(function(input,gameprocessed)
	if gameprocessed then return end
	-- If you crouch while running
	if IsCrouching == true then 
		if input.KeyCode == Enum.KeyCode.W then
			run = false
			char:SetAttribute("IsRunning", false)
			if Track1 then
				Track1.Priority = Enum.AnimationPriority.Movement
				Track1:Stop(0.300000001)
			end
			hum.WalkSpeed = 8
			runs.Value = false
		end
	end
end)

UIS.InputBegan:Connect(function(input,gameprocessed)
	if gameprocessed then return end
	-- If you crouch while running
	if IsCrouching == true then 
		if input.KeyCode == Enum.KeyCode.S then
			run = false
			char:SetAttribute("IsRunning", false)
			if Track1 then
				Track1.Priority = Enum.AnimationPriority.Movement
				Track1:Stop(0.300000001)
			end
			hum.WalkSpeed = 8
			runs.Value = false
		end
	end
end)



-- Ending the Running Script


UIS.InputEnded:Connect(function(input,gameprocessed)
	if gameprocessed then return end
	if input.KeyCode == Enum.KeyCode.W and run ~= false and IsCrouching == false and not IsBlocking then
		run = false
		char:SetAttribute("IsRunning", false)
	if Track1 then	
			Track1.Priority = Enum.AnimationPriority.Movement
			Track1:Stop(0.300000001)
		end	
	
		hum.WalkSpeed = 16
		runs.Value = false
	end
 
end)

if IsBlocking and IsRunning then 
	run = false
	char:SetAttribute("IsRunning", false)
	if Track1 then	
		Track1.Priority = Enum.AnimationPriority.Movement
		Track1:Stop(0.300000001)
	end	
	hum.WalkSpeed = 4
	runs.Value = false
end

This is the module script that I was using.

local module = {}

function module.CheckForAttributes(char,attack,stun,ragdoll,equipped, blocking)
	local attacking = char:GetAttribute("Attacking")
	local stunned = char:GetAttribute("Stunned")
	local IsEquipped = char:GetAttribute("Equipped")
	local IsRagdoll = char:GetAttribute("IsRagdoll")
	local IsBlocking = char:GetAttribute("IsBlocking")
	
	local stop = false
	
	if attacking and attack then stop = true end 
	if stunned and stun then stop = true end 
	if IsRagdoll and ragdoll then stop = true end 
	if equipped ~= nil and not IsEquipped then stop = true end
	if blocking ~= nil and IsBlocking then stop = true end
	
	return stop
end

return module

any errors where the code breaks?

and when you had the local script, where was it?

im guessing the part that is breaking is the “GetAttribute” part, but an output would be nice

Please show the output and where the error is. It could just be you set a value on the client and it did not replicate to the server.

There was nothing in output so I was confused. What I meant by broken is the rest of the script not
running my bad.

I checked on the server and client if there was anything different between them and there was nothing. No different attributes or anything. Anyways here’s a video of the output.

The local script is in startercharacterscripts yeah it probably is that part. I tried printing it and it came out false. It’s probably not detecting it even though when I select it from the local player it is said that they’re not blocking or stunned etc.