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
script.Parent.Touched:Connect(function(hit)
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
script.Parent.Punch:Play()
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()
print("Blocking")
end
end)
when the Bool_Value change the script doesn’t change to not blocking.
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
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
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
script.Parent.Touched:Connect(function(hit)
if hit and hit.Parent:FindFirstChild("Humanoid") and hit.Parent:WaitForChild("Blocking").Value == false then
print(hit.Parent.Blocking)
print(hit.Parent.Blocking.Value)
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
end
end)