How to update this?

Hello everyone i have been making a block system to my combat system
so i added a bool_Value to the player called blocking it goes true when the player Holds Q

	if hit and hit.Parent:FindFirstChild("Humanoid") and hit.Parent:WaitForChild("Blocking").Value == false then
		script.Parent.CanTouch = false
		hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 2.5
		print("not Blocking")
	elseif hit.Parent:FindFirstChild("Humanoid") and hit.Parent:WaitForChild("Blocking").Value == true and hit.Parent ~= script.Parent.Parent.Parent then
		hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 0.5
	script["Block Sound Effect"]:Play()

when the Bool_Value change the script doesn’t change to not blocking.

1 Like

If you set CanTouch to false, touched event will never play again

1 Like

I already made it turn true in the Server script when the remote fires from the client

1 Like

See, sorry for that, your script is sort of not the way it should be done, i would reccomend reworking your entire system like this:

  • in tools you have local script that checks if key is pressed, then it sends mouse position or target or smth like that if it’s important

  • On Server, you detect tool by simply finding first tool inside player’s character, then create bounding box or hitbox in front of player that detects hits & stuff

  • Eventually another module take care of blocking, and then sets some value when key is pressed to true or false

  • Back to weapon, it checks if hit is player and if there is block, if not deal damage, else do something else

1 Like

The problem is it is not actually a tool it is a combat system when player press E button he can start fighting and there is also a kick in it the problem is all of the scripts works perfectly except this one
But also thanks for these points it is useful when i make new ones

1 Like

There might be silent error, i call them because they make no output prints and ect. you have to experiment on your own, but doing system more OOP and modular would make it far easier

1 Like

I only now need to know how to make the script’s function with the blocking player to change when the player stops blocking

The script that changes the bool value to true or false isn’t in a local script, right?



Have you checked in game if the bool value changes or not?

yes i did it changes


try printing the bool value

	if hit and hit.Parent:FindFirstChild("Humanoid") and hit.Parent:WaitForChild("Blocking").Value == 	false then
1 Like

it prints false even when i change it [AFK]

Can you show me the part of the script where it changes the bool value?

1 Like
game.ReplicatedStorage.Blocking.OnServerEvent:Connect(function(Player , Blocking)
	local Character = Player.Character or Player.CharacterAdded:Wait()
	if Blocking == true then
		Character:WaitForChild("Blocking").Value = true
	elseif Blocking == false then
		Character:WaitForChild("Blocking").Value = false

Try refrencing the Blocking bool value in the server script instead of the local script.

It already works and changes the problem is that the hitbox don’t get that the value have changed

Are you sure? Play the game and change game type to server and then check the value.

1 Like

it changes normally i really appreciate your help

This text will be blurred

If this doesn’t work then i have no idea.
try removing the WaitForChild