Hi.
I’m trying to make a combat system for my game, but when I fire the event, it fires twice. I think It’s a UIS’ problem.
My code:
function miModulo.LocalScript:StandM1(standName)
--Main Variables
local UserInputService = game:GetService("UserInputService")
local combo = 0
local littleDebounce = false
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local timeToClick = 1
local event = game:GetService("ReplicatedStorage").RemoteEvents.NormalStandClick
UserInputService.InputBegan:Connect(function(input, gpe)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if not gpe and character:FindFirstChildOfClass("Model") and character:FindFirstChildOfClass("Model").Name == standName and littleDebounce == false then
littleDebounce = true
delay(.1, function()
littleDebounce = false
end)
if combo == 0 then
combo = 1
event:FireServer(1)
print(1)
wait(timeToClick)
if combo == 1 then
combo = 0
end
elseif combo == 1 then
combo = 2
event:FireServer(2)
print(2)
wait(timeToClick)
if combo == 2 then
combo = 0
end
elseif combo == 2 then
combo = 3
event:FireServer(3)
print(3)
wait(timeToClick)
if combo == 3 then
combo = 0
end
elseif combo == 3 then
combo = 4
event:FireServer(4)
print(4)
wait(timeToClick)
if combo == 4 then
combo = 0
end
elseif combo == 4 then
combo = 0
event:FireServer(5)
print(5)
end
end
end
end)
end
It is in a module script and being required in a local script on starter character scripts.
Thanks for reading.