Usually, I find a forum with a similar issue or search on Google, but I can’t find a good solution to this. Because the solution that works also leads to another issue (I’ll address later on)
-
What do you want to achieve? To have a working MB1 and MB2 keys for a fighting game
-
What is the issue? My CombatClient script has randomly just stopped working. I have a good reason why I’m saying this, I swear, because the same script is present in another game, and it works flawlessly.
here is the script
local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local Humanoid = character:WaitForChild("Humanoid")
local M1 = Humanoid:LoadAnimation(script.Animations.M1)
local M2 = Humanoid:LoadAnimation(script.Animations.M2)
local M3 = Humanoid:LoadAnimation(script.Animations.M3)
local M4 = Humanoid:LoadAnimation(script.Animations.M4)
local combo = 1
local cooldown = false
UIS.InputEnded:Connect(function(I,E)
if plr.Character:WaitForChild("Lobby").Value == true then return end
if E then return end
if I.UserInputType == Enum.UserInputType.MouseButton1 then
if character:FindFirstChild("Stunned") then return end
if cooldown == true then return end
spawn(function()
cooldown = true
script.Swing:Play()
task.wait(.5)
cooldown = false
end)
if combo == 3 then
game.ReplicatedStorage.MainEvent:FireServer("Last")
M1:play()
combo = combo + 1
spawn(function()
task.wait(.75)
combo = 1
end)
elseif combo == 2 then
game.ReplicatedStorage.MainEvent:FireServer("Regular")
M2:play()
combo = combo + 1
elseif combo == 1 then
game.ReplicatedStorage.MainEvent:FireServer("Regular")
M1:play()
combo = combo + 1
end
end
if I.UserInputType == Enum.UserInputType.MouseButton2 and combo == 4 then
if character:FindFirstChild("Stunned") then return end
if cooldown == true then return end
spawn(function()
cooldown = true
script.Swing:Play()
task.wait(.5)
cooldown = false
end)
game.ReplicatedStorage.MainEvent:FireServer("Bonus")
M4:play()
script.SwingKick:Play()
spawn(function()
task.wait(.1)
combo = 1
end)
end
end)
-- Console edition Keybinds
local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local Humanoid = character:WaitForChild("Humanoid")
local M1 = Humanoid:LoadAnimation(script.Animations.M1)
local M2 = Humanoid:LoadAnimation(script.Animations.M2)
local M3 = Humanoid:LoadAnimation(script.Animations.M3)
local M4 = Humanoid:LoadAnimation(script.Animations.M4)
local combo = 1
local cooldown = false
UIS.InputEnded:Connect(function(I,E)
if E then return end
if I.KeyCode == Enum.KeyCode.ButtonB then
if character:FindFirstChild("Stunned") then return end
if cooldown == true then return end
spawn(function()
cooldown = true
script.Swing:Play()
task.wait(.5)
cooldown = false
end)
if combo == 3 then
game.ReplicatedStorage.MainEvent:FireServer("Last")
M1:play()
combo = combo + 1
spawn(function()
task.wait(.75)
combo = 1
end)
elseif combo == 2 then
game.ReplicatedStorage.MainEvent:FireServer("Regular")
M2:play()
combo = combo + 1
elseif combo == 1 then
game.ReplicatedStorage.MainEvent:FireServer("Regular")
M1:play()
combo = combo + 1
end
end
if I.KeyCode == Enum.KeyCode.ButtonB and combo == 4 then
if character:FindFirstChild("Stunned") then return end
if cooldown == true then return end
spawn(function()
cooldown = true
script.Swing:Play()
task.wait(.5)
cooldown = false
end)
game.ReplicatedStorage.MainEvent:FireServer("Bonus")
M4:play()
script.SwingKick:Play()
spawn(function()
task.wait(.1)
combo = 1
end)
end
end)
My issue is, if I.UserInputType == Enum.UserInputType.MouseButton1 then is just being skipped over. causing none of my mouse keys to function, and the weirder issue is that the console method
if I.KeyCode == Enum.KeyCode.ButtonB then works without any issues
- What solutions have you tried so far? I tried converting UserInputType into KeyCode, which worked. But it also made every single key on the keyboard trigger that function
Sorry if I added too many details or words, never made a forum post before