Hello guys im having an issue with a framework the issue is while player 1 holding if player 2 hold and release player 1 stucks in holding situation which means remote aint firing for both separately i tried a lot of ways but couldnt fix i really need help with this one please let me know all your opinions about how can i fix this.
StarterCharacterScript
Local Script
local UIS = game:GetService("UserInputService")
local players = game:GetService("Players")
local repStore = game:GetService("ReplicatedStorage")
local remotes = repStore.Remotes
--repStore.Remotes
local plr = players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
--| Input
local keys = {"Z"; "X"; "C"; "V";"F",}
local function ibegan(input, other)
local key = UIS:GetStringForKeyCode(input.KeyCode)
if other or table.find(keys, key) == nil then return end
if plr.CanUseSkill.Value == true and hum:GetState() ~= Enum.HumanoidStateType.Dead and hum.FloorMaterial ~= nil and hum.FloorMaterial ~= Enum.Material.Air then
remotes.Start:FireServer(key)
end
end
local function iended(input, other)
local key = UIS:GetStringForKeyCode(input.KeyCode)
if other or table.find(keys, key) == nil then return end
remotes.Ended:FireServer(key)
end
UIS.InputBegan:Connect(ibegan)
UIS.InputEnded:Connect(iended)
local function checkKey(key)
return UIS:IsKeyDown(Enum.KeyCode[key])
end
remotes.CheckKey.OnClientInvoke = checkKey
--| Client
local function getSkill(class, skill)
local skills = script:FindFirstChild(class)
if not skills then warn(("[%s]: No class found named '%s'"):format(script.Name:upper(), class)) return end
for name, funcs in pairs(require(skills)) do
if name ~= skill then continue end
return funcs
end
end
local function client(char, class, skill, func)
local funcs = getSkill(class, skill)
funcs[func](char)
end
remotes.Client.OnClientEvent:Connect(client)
ServerScriptService
Script
local players = game:GetService("Players")
local repStore = game:GetService("ReplicatedStorage")
local remotes = repStore.Remotes
local cdreg = {}
local dbreg = {}
local hreg = {}
local RagdollModule = require(game.ReplicatedStorage.EffectsModule.RagdollModule)
local function getSkill(plr, key)
local class = plr.Class.Value
if class == "" then return end
local skills = script:FindFirstChild(class)
if not skills then warn(("[%s]: No class found named '%s' for player %s"):format(script.Name:upper(), class, plr.Name)) return end
for _, s in pairs(require(skills)) do
if s.Key ~= key then continue end
return s
end
end
local function cooldown(plr, key, cd)
dbreg[plr] = false
task.delay(cd, function()
cdreg[plr][key] = nil
hreg[plr][key] = nil
end)
end
local function start(plr, key)
local char = plr.Character
if not char or not char:FindFirstChild("Humanoid") or cdreg[plr][key] or dbreg[plr] then return end
local skill = getSkill(plr, key)
if not skill then return end
print(("[%s]: %s used '%s' of class '%s'"):format(script.Name:upper(), plr.Name, skill.Name, plr.Class.Value))
dbreg[plr] = true
if skill.HoldDur then
hreg[plr][key] = tick()
task.delay(skill.HoldDur, function()
if not hreg[plr][key] then return end
local check = remotes.CheckKey:InvokeClient(plr, key)
if not check then return end
cdreg[plr][key] = true
local cd = skill.Release(char, skill.HoldDur)
cooldown(plr, key, cd or skill.Cooldown)
end)
skill.Hold(char)
return
end
cdreg[plr][key] = true
local cd = skill.Func(char)
cooldown(plr, key, cd or skill.Cooldown)
end
remotes.Start.OnServerEvent:Connect(start)
local function released(plr, key)
local char = plr.Character
if not char or not char:FindFirstChild("Humanoid") or cdreg[plr][key] then return end
local skill = getSkill(plr, key)
if not skill or not skill.HoldDur then return end
local tim = hreg[plr][key]
if not tim then return end
local min = skill.MinHoldDur or 0
if tick() - tim < min then wait(min - (tick() - tim)) end
cdreg[plr][key] = true
local cd = skill.Release(char, tick() - tim)
cooldown(plr, key, cd or skill.Cooldown)
end
remotes.Ended.OnServerEvent:Connect(released)
local function added(plr)
cdreg[plr] = {}
hreg[plr] = {}
--temp
local class = Instance.new("StringValue", plr)
class.Name = "Class"
class.Value = 'Ligma'
local CanUseSkill = Instance.new("BoolValue")
CanUseSkill.Value = true
CanUseSkill.Name = "CanUseSkill"
CanUseSkill.Parent = plr
local Form = Instance.new("StringValue")
Form.Value = "None"
Form.Name = "Form"
Form.Parent = plr
end
players.PlayerAdded:Connect(added)
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
task.wait(0.1)
RagdollModule:RigPlayer(Character)
local FolderToFilterForMouse = Instance.new("Folder")
FolderToFilterForMouse.Name = "FolderToFilterForMouse"
FolderToFilterForMouse.Parent = Character
end)
end)