Hello.
Right now, I have 3 keys that all do something (A obviously for moving left, D for moving right, and C key for a blocking manoeuvre.)
When I hold down all 3 keys at once, this happens:
(In the video I gradually press keys until my block suddenly gets cancelled, and when I let go of either A or D it messes up and re-does my block mechanic)
Here is the code:
(Server, Block Move Manager) Parented Under ServerScriptService
task.wait()
local module=require(game.ServerScriptService.Game)
local rs=game:GetService("ReplicatedStorage")
local remotes=rs:FindFirstChild("Remotes")
local moves=remotes:FindFirstChild("Moves")
local BlockInfoList={}
moves.Block.OnServerEvent:Connect(function(player,character,enable)
print(enable,"GO!")
if player and character and character:FindFirstChild("Humanoid") and character:FindFirstChild("Humanoid").Health>0 and character:GetAttribute("Block")~=nil and module.AnimationList[player.Name]~=nil then
if enable==true and character:GetAttribute("Block")==false then
BlockInfoList[player.Name]=false
character:FindFirstChild("Humanoid").WalkSpeed=0
character:FindFirstChild("Humanoid").JumpPower=0
local animlist=module.AnimationList[player.Name]
animlist.BlockIntro:Play(0.0000001)
animlist.Block:Play(0.0000001)
animlist.BlockIntro.Stopped:Wait()
if BlockInfoList[player.Name]==false then character:SetAttribute("Block",true) end
elseif enable==false then
character:FindFirstChild("Humanoid").WalkSpeed=19
character:FindFirstChild("Humanoid").JumpPower=38
local animlist=module.AnimationList[player.Name]
animlist.Block:Stop(0.0000001)
character:SetAttribute("Block",false)
if BlockInfoList[player.Name]~=nil and BlockInfoList[player.Name]==false then BlockInfoList[player.Name]=true animlist.BlockIntro:Stop(0.0000001) end
end
end
end)
(Client, Move Input Detector) Parented Under StarterPlayerCharacter
game.UserInputService.InputBegan:Connect(function(inp,gpe)
if not gpe and inp.KeyCode==Enum.KeyCode.C then
game.ReplicatedStorage.Remotes.Moves.Block:FireServer(script.Parent,true)
end
end)
game.UserInputService.InputEnded:Connect(function(inp,gpe)
if not gpe and inp.KeyCode==Enum.KeyCode.C then
game.ReplicatedStorage.Remotes.Moves.Block:FireServer(script.Parent,false)
end
end)
Any help is appreciated!