BoolValue check not working?

Hey! Trying to make a blocking system, to check if the player is blocking. However, it can’t detect if the BoolValue is true or false maybe?? Please help, here is my script:

local Anim1 = Instance.new("Animation")
local Anim2 = Instance.new("Animation")
local Anim3 = Instance.new("Animation")
Anim1.AnimationId = "rbxassetid://6994805911"
Anim2.AnimationId = "rbxassetid://6994937254"
Anim3.AnimationId = "rbxassetid://6994943940"
while true do
	wait(0.3)
	local c = script.Parent
	c.Humanoid:LoadAnimation(Anim1):Play()
	for i, v in pairs(game.Workspace:GetChildren()) do
		if v:IsA("Model") and v:FindFirstChild("HumanoidRootPart") then
			local vector = (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position)
			if vector:Dot( c.HumanoidRootPart.CFrame.lookVector ) < 0 then
				if (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 5 then
					print(c.Name .. " is now attacking " .. v.Name)
					if v.Conditions.IsBlocking.Value == true then
						print(v.Name.. " is now blocking!")
						v.Conditions.IsAttackedWhileBlocking.Value = true
					end
					c.Conditions.IsAttacking.Value = true
					v.Conditions.IsStunned.Value = true
					local CurrentDamage = v.Conditions.CurrentDamage
					v.Humanoid:TakeDamage(1)
					CurrentDamage.Value += 1
					if v:FindFirstChild("BillboardGui"):FindFirstChild("TextLabel") then
						v.BillboardGui.TextLabel.Text = CurrentDamage.Value .. "%"
					end
					c.Conditions.IsAttacking.Value = false
					v.Conditions.IsStunned.Value = false
					wait()
					if v.Conditions.IsAttackedWhileBlocking.Value == true then
						v.Conditions.IsAttackedWhileBlocking.Value = false	
					end
				end
			end
		end
	end
end)

No errors, please help!

1 Like

If you’re me I would use :GetPropertyChangedSignal (“Value”)

The problem is that when a player attacks me while I hold block, the server doesn’t know. Trying to look for ways to help fix that but I’ll try your method anyways

Blocking isn’t in a tool either…

It wont detect because the script won’t detect if it was changed

just use what I said

Alright I’ll try it, give me a sec

Got an error, it says "true is not a valid property name. " on line 18, heres what I put

Blocking:GetPropertyChangedSignal("true"):Connect(function(property)
						print(v.Name.. " is now blocking!")
						v.Conditions.IsAttackedWhileBlocking.Value = true
					end)

how should i use it?

It’s because you’re using an invalid property, change it to “Value”

Sorry, but where is the BoolValue? There is so much code, I can’t find it. SUGGESTION: Use comments!

Still does not work… I’ve tried nearly everything and yet it still doesn’t work, what do you think I should do now? I’m getting no errors either so…

Maybe because you’re trying to change a variable inside a function, which won’t work outside

maybe put the attack code inside the function? might work

Try using print statements to find the answer. Trust me, this helps a lot! Often times, I will be coding, and the problem is either that the BoolValue is being set wrongly, or the script is wrong. It is always one of those factors that you need to think about. Also, take a peek into the workspace and look at the bool value to make sure it is correct. Lemme know the result :smiley:

Hi! Sorry that it seems you never found a solution to this problem.

The problem is likely that you’re attempting to set a BoolValue with a LocalScript and read its value with a normal Script. This means that the change to the value will only be observed on the client, and it will not be updated globally.

To solve this problem, you could use a RemoteEvent to handle client-server interaction and communicate to the server when you’re blocking.