I have a made a combat system. But it seems to be very rough and not smooth like I want it to be. For example, there seems to be input latency when playing the on site game. Also, when I play in roblox studio, it seems to jump over the cooldown system put in place and allows for two M1’s to be rendered at once, this also applys in the actual game.
Here are some videos and code:
In the on site game:
In Roblox Studio:
As you can see in roblox studio, it starts off smooth, then it does that same jumping over cooldown thing that is done in the actual on site game.
Here is a sample of my combat system:
if UserInputState ~= Enum.UserInputState.Begin then return end
if thresholdMet(lastM1End, .3) and tick() - lastComboEnd > 1 and CombatCheck:CheckAll(Character) == false then
local Class = CombatCheck:CheckClass(Character)
local anims = RPF.Assets.Default.Animations.Class:FindFirstChild(Class):GetChildren()
if tick() - lastM1End > 1 then
Character:SetAttribute("Combo", 1)
end
local combo = Character:GetAttribute("Combo")
local variant = nil
if combo == 4 and UIS:IsKeyDown(Enum.KeyCode.Space) then
load = Humanoid.Animator:LoadAnimation(varAnims[1])
load:Play(load:GetTimeOfKeyframe("Done"))
variant = "UpTilt"
elseif combo == 4 and Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
load = Humanoid.Animator:LoadAnimation(varAnims[2])
load:Play(load:GetTimeOfKeyframe("Done"))
variant = "DownSlam"
else
load = Humanoid.Animator:LoadAnimation(anims[combo])
load:Play(load:GetTimeOfKeyframe("Done"))
end
load:AdjustSpeed(load.Speed + Player:GetNetworkPing())
Humanoid.WalkSpeed = 0
local subject = SubjectModule.new(Character.Torso, Humrp, Humanoid)
load.Stopped:Connect(function()
subject:Destroy()
end)
lastM1End = tick()
Humanoid.WalkSpeed = 16
if combo == 4 then
Character:SetAttribute("Combo", 1)
lastComboEnd = tick()
else
Character:SetAttribute("Combo", combo + 1)
end
local data = {
Attack = true,
SkillName = "M1",
SkillSet = "Default",
Target = nil,
Variant = variant,
Combo = combo,
RightArm = Character["Right Arm"],
LeftArm = Character["Left Arm"],
HumanoidRootPart = Character["HumanoidRootPart"],
Class = Class,
LoadTime = load:GetTimeOfKeyframe("Done")
}
Functions.FireServer(data, "Skill")
end
end
type or paste code here
Does someone have a solution on how I can get the smooth combat transitions I want?