I recently made a combat system that uses boolvalues to determine if a player is block or not, and I’m encountering an issue with the bool value.
First, I put a folder into StarterCharacterScripts named “PlayerValues” with 3 boolvalues:
“CanCombat”, “IsBlocking”, and “IsParrying”.
(I didn’t feel like making an entire script for cloning a folder into the player, please tell me if this was the reason behind my problems)
“CanCombat” is true by default, and the other values are false.
I also had blocking dummies, which were just dummies with the “IsBlocking” value set to true by default.
Then, I made a script to set the “IsBlocking” value to true when the player presses the block button. Everything was fine until I went to test it with my friend. When I press the block button, it does everything I want it to (Setting the block value to true, applying an effect, etc.), except my friend was able to hit me through my block. I thought nothing of it and chalked it down as another silly mistake I made, but after an hour of testing and messing around with the script, my brain pumped out approximately 0 ideas of why attacks were going through block.
Here is the video showing that the blocking “works”:
Here is the portion of the script handling the blocking:
Server Script:
blockRemote.OnServerEvent:Connect(function(plr, isBlocking, isParrying)
local hum = plr.Character.Humanoid
local blockAnim = game.ReplicatedStorage.Animations.BlockAnim
local load = hum.Animator:LoadAnimation(blockAnim)
load:Play()
print(isBlocking)
if isBlocking then
local char = plr.Character
local parryWindow = .35
local blockfx = fxs.BlockEffect
local blockFxAttachment = blockfx.Attachment:Clone()
blockFxAttachment.Parent = char.PrimaryPart
load:Play()
for i,v in pairs(blockFxAttachment:GetChildren()) do
if v:IsA("ParticleEmitter") then
v.Enabled = true
end
end
wait(parryWindow)
isParrying = false
blockRemote:FireClient(plr, isBlocking, isParrying)
elseif not isBlocking then
load:Stop()
local primaryPart = plr.Character.PrimaryPart
for i,v in pairs(primaryPart:GetChildren()) do
if v:IsA("Attachment") and v.Name == "Attachment" then
v:Destroy()
end
end
local blockFxInbody = plr.Character.PrimaryPart:FindFirstChild("Attachment")
if blockFxInbody then
for i,v in pairs(blockFxInbody:GetChildren()) do
if v:IsA("ParticleEmitter") then
v.Enabled = false
game.Debris:AddItem(blockFxInbody, .5)
end
end
end
end
end)
Local script:
uis.InputBegan:Connect(function(input, gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.F and plrValues.CanCombat.Value and deb == false and blockDeb == false and canBlock then
canBlock = false
char.Humanoid.WalkSpeed = 3
char.Humanoid.JumpHeight = 0
deb = true
blockDeb = true
isBlocking.Value = true
isParrying.Value = true
blockRemote:FireServer(isBlocking.Value, isParrying.Value)
I titled the post “Bool values not updating?” because although the player holding block does not work, the blocking dummy with the value set to true by default does.
Video of this:
This is also my first time posting on the devforum, please tell me if I did anything wrong.