My game has this really weird issue that sometimes, the game lags a LOT. And I don’t mean FPS. Everyone can still move around normally, but they can’t use any attacks properly because they are delayed by like 30 seconds (The attacks are serversided.)
Eventually, the lag ends and people can use attacks normally.
The weird thing is, it happens in random times. There are days where it doesn’t happen at all, days where it happens for 5 minutes, days where it lasts forever etc.
It’s really been bugging me.
Here’s the client input script:
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local character = player.Character or player.CharacterAdded:Wait()
local root : Part = character:WaitForChild("HumanoidRootPart")
script.InputServer.Enabled = true
UIS.InputBegan:Connect(function(input, GPE)
if not GPE and input.KeyCode.Name ~= "Unknown" then
script.Input:FireServer(input.KeyCode.Name, root.CFrame)
end
end)
UIS.InputEnded:Connect(function(input, GPE)
if not GPE and input.KeyCode.Name ~= "Unknown" then
script.Input:FireServer(input.KeyCode.Name.. "_UP", root.CFrame)
end
end)
script.Input.OnClientEvent:Connect(function(input)
script.Input:FireServer(input)
end)
mouse.Button1Down:Connect(function()
if script.Parent:WaitForChild("MobileSupport").Enabled == false and not game.Players.LocalPlayer.Character:FindFirstChildWhichIsA("Tool") then
script.Input:FireServer("M1")
end
end)
script.ChildAdded:Connect(function(child)
if child.Name == "Attacks" then
game.ReplicatedStorage.GUI.NewKeybinds:Fire(child)
end
end)
And here’s the server input script:
local attacks = script.Parent:WaitForChild("Attacks")
local player : Player = script.Parent.Parent.Parent
local character : Model = player.Character or player.CharacterAdded:Wait()
local dataStore = require(game:GetService("ReplicatedFirst").Modules.DataStores)
local stand : string = dataStore:GetData(player, "Stand")
function validate(key)
stand = dataStore:GetData(player, "Stand")
if (character.Humanoid.Health <= 0 or character:HasTag("Disabled") or character.RagdollTrigger.Value == true) then return false end
if key == "T" or key == "F" or key == "B" then
if stand == "King Crimson" then
return true
end
end
if key == "E_UP" or key == "X_UP" or key == "P" then
return true
end
if script.Parent.Attacks:FindFirstChild(key) and not player:WaitForChild("Cooldowns"):FindFirstChild(key) and not character:HasTag("Active") and not character:HasTag("Stunned") and character.HumanoidRootPart.Anchored == false then
return true
else
return false
end
end
script.Parent.Input.OnServerEvent:Connect(function(firedPlayer, key, rootCFrame)
stand = dataStore:GetData(player, "Stand")
if firedPlayer ~= player then
firedPlayer:Kick("You were kicked from the game for suspicious activity. If you believe that this kick was unfair, please contact the owner of the game.")
else
if validate(key) then
script.Parent.Attacks[key]:Fire(player, rootCFrame)
end
if key == "N" and not player:WaitForChild("Cooldowns"):FindFirstChild(key) and not character:HasTag("Active") and not character:HasTag("Stunned") and character.HumanoidRootPart.Anchored == false then
game.ReplicatedStorage.Effects.Quote:Fire(player)
end
end
end)
This is a game breaking issue, I would really appreciate any help.