I’m making a block script for my fighting game. It worked yesterday, but after trying it today it all of a sudden doesn’t work. If I’m being honest, I have no idea what’s wrong.
-- variables yayayayayayaya
local player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local humanoid = player.Character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local uis = game:GetService("UserInputService")
local cas = game:GetService("ContextActionService")
local rs = game:GetService("RunService")
local blockbool = player.PlayerScripts:WaitForChild("blockbool")
local actualshield = player.PlayerScripts:WaitForChild("blockshield")
local blocka = Instance.new("Animation")
blocka.AnimationId ="rbxassetid://7024791352"
blockanim = animator:LoadAnimation(blocka)
-- actual block funny
local function block(inputObject, gpa)
print ("the function ran")
if uis:IsKeyDown(Enum.KeyCode.F) == true and blockbool == false then
print ("the blockbool thing worked")
blockbool.Value = true
actualshield.Parent = player.Character
humanoid.WalkSpeed = 10
repeat
rs.Heartbeat:Wait()
print ("its repeating")
blockanim:Play()
uis:IsKeyDown(Enum.KeyCode.F)
until
uis:IsKeyDown(Enum.KeyCode.F) == false
end
actualshield.Parent = player.PlayerScripts
print ("it shouldve stopped now")
blockanim:Stop()
humanoid.WalkSpeed = 30
wait(1.5)
blockbool.Value = false
end
cas:BindAction("block", block, false, Enum.KeyCode.F)
In the output the it prints that the function ran, except it completely ignores the if statement. In fact, the blockbool isn’t being changed in the first place (it starts as false as all bools do), so I don’t know why it won’t fire. Any help is appreciated, including any improvements to the script in the first place 