Random servers in my sword fighting game are experiencing major delay on a lot of factors such as the sword swing being delayed by around 1 second (may seem minimal but very noticeable in game) and chat messages taking significantly longer to appear. It’s very difficult to pinpoint the cause of this because it’s only happening in some servers, while other servers can be running for days and be completely fine. I’d like to think that my game is pretty well optimized, but I doubt this is a Roblox issue and it’s extremely annoying to the game.
These are the main scripts that I can think might be causing the issue, however I’m looking to see if anyone can identify some major issues in this code.
SwordMain Script (ServerSided in Tool)
Note: There are many different swords (maybe 6 on average) being cloned into a player’s backpack based on their stats when they spawn/respawn.
Tool = script.Parent.Parent;
Handle = Tool:WaitForChild("Handle")
Mesh = Handle:WaitForChild("Mesh")
Players = game:GetService("Players")
Debris = game:GetService("Debris")
RunService = game:GetService("RunService")
BaseUrl = "http://www.roblox.com/asset/?id="
Grips = {
Up = CFrame.new(0, 0, -1.5, 0, 0, 1, 1, 0, 0, 0, 1, 0),
Out = CFrame.new(0, 0, -1.5, 0, -1, -0, -1, 0, -0, 0, 0, -1),
}
DamageValues = {
BaseDamage = 5,
SlashDamage = 10,
LungeDamage = 30,
}
Damage = DamageValues.BaseDamage
Sounds = {
Slash = Handle:WaitForChild("Slash"),
Lunge = Handle:WaitForChild("Lunge"),
Unsheath = Handle:WaitForChild("Unsheath"),
}
LastAttack = 0
ToolEquipped = false
Tool.Enabled = true
function SwordUp()
Tool.Grip = Grips.Up
end
function SwordOut()
Tool.Grip = Grips.Out
end
function IsTeamMate(Player1, Player2)
return (Player1.TeamColor==Player2.TeamColor);
end
function TagHumanoid(humanoid, player)
local Creator_Tag = Instance.new("ObjectValue")
Creator_Tag.Name = "creator"
Creator_Tag.Value = player
Debris:AddItem(Creator_Tag, 2)
Creator_Tag.Parent = humanoid
end
function UntagHumanoid(humanoid)
for i, v in pairs(humanoid:GetChildren()) do
if v:IsA("ObjectValue") and v.Name == "creator" then
v:Destroy()
end
end
end
function Attack()
Damage = DamageValues.SlashDamage
Sounds.Slash:Play()
local Anim = Instance.new("StringValue")
Anim.Name = "toolanim"
Anim.Value = "Slash"
Anim.Parent = Tool
end
function Lunge()
Damage = DamageValues.LungeDamage
Sounds.Lunge:Play()
local Anim = Instance.new("StringValue")
Anim.Name = "toolanim"
Anim.Value = "Lunge"
Anim.Parent = Tool
wait(0.25)
SwordOut()
wait(0.75)
SwordUp()
end
function Blow(Hit)
if not CheckIfAlive() then
return
end
local character = Hit.Parent
local humanoid = character:FindFirstChild("Humanoid")
if not humanoid then
return
end
local Target = Players:GetPlayerFromCharacter(character);
local Current = Player:DistanceFromCharacter(Target.Character:FindFirstChild'HumanoidRootPart'.Position)
local Connector = nil;
if Current <= 10 then
if Target then
Connector = humanoid.Died:Connect(function()
Player.Character.Humanoid.Health = Player.Character.Humanoid.MaxHealth
end);
end
UntagHumanoid(humanoid);
TagHumanoid(humanoid, Player);
humanoid:TakeDamage(Damage);
wait(0.5);
Connector:Disconnect();
end
end
function Activated()
if not Tool.Enabled or not ToolEquipped or not CheckIfAlive() then
return
end
Tool.Enabled = false
local Tick = RunService.Stepped:wait()
if (Tick - LastAttack) < 0.2 then
Lunge()
else
Attack()
end
Damage = DamageValues.BaseDamage
LastAttack = Tick
Tool.Enabled = true
end
function CheckIfAlive()
return (Character and Humanoid.Health > 0)
end
function Equipped()
Character = Tool.Parent
Player = Players:GetPlayerFromCharacter(Character)
Humanoid = Character:FindFirstChild("Humanoid")
local RootPart = Character:FindFirstChild("HumanoidRootPart")
if not CheckIfAlive() then
return
end
ToolEquipped = true
Sounds.Unsheath:Play()
end
function Unequipped()
ToolEquipped = false
end
SwordUp()
Handle.Touched:Connect(Blow)
Tool.Activated:Connect(Activated)
Tool.Equipped:Connect(Equipped)
Tool.Unequipped:Connect(Unequipped)
Stand Still for 7 Seconds to Teleport to Safezone
Server-Side
local Debounce = {}
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Bind = game:GetService("ServerStorage"):WaitForChild("Teleport")
local TeleportEvent = Instance.new("RemoteFunction",ReplicatedStorage)
TeleportEvent.Name = "TeleportEvent"
script.Parent.Touched:Connect(function(Hit)
local FF = Hit.Parent:FindFirstChild("ForceField")
if FF then
FF:Destroy()
local Plr = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Plr then
local PlayerGui = Plr:WaitForChild("PlayerGui",4)
if PlayerGui and not PlayerGui:FindFirstChild("Teleport") then
local Clone = script.Teleport:Clone()
Clone.Parent = PlayerGui
end
end
end
end)
TeleportEvent.OnServerInvoke = function(plr,key,gui)
if table.find(Debounce,plr.UserId) then
plr:Kick("Abusing Teleport to Spawn")
else
if key == "{4)z}U$e2%zRGMW" then
local Start = tick()
repeat
wait(.01)
if plr.Character.Humanoid.MoveDirection.Magnitude > 0 then
return true
end
until tick() - Start >= 7
if plr.Character:FindFirstChild("ForceField") then return true end
local FF = Instance.new("ForceField")
FF.Visible = false
FF.Parent = plr.Character
Bind:Fire(plr)
delay(.2,function()
if not plr.Character:FindFirstChild("ForceField") then
local FF = Instance.new("ForceField")
FF.Visible = false
FF.Parent = plr.Character
return true
end
end)
gui:Destroy()
return true
else
plr:Kick("Invalid key")
end
end
end
Client-Side
local RE = game:GetService("ReplicatedStorage"):WaitForChild("TeleportEvent")
local Timer = 5
local Stop = false
local Player = game.Players.LocalPlayer
local Begin = false;
local Counter = nil;
script.Parent.MouseButton1Down:Connect(function()
if not Begin then
Counter = tick();
Begin = true;
RE:InvokeServer("{4)z}U$e2%zRGMW",script.Parent.Parent)
Begin = false;
end;
end);
game:GetService("RunService"):BindToRenderStep("Core", Enum.RenderPriority.First.Value, function()
if not Player or not Player.Character then
return
end
local HumanoidRootPart = Player.Character:FindFirstChild("HumanoidRootPart")
local Humanoid = Player.Character:FindFirstChild("Humanoid")
if not Humanoid or not HumanoidRootPart then
return
end
if Begin then
local TimeLeft = 8 - (tick() - Counter)
if TimeLeft > 1 then
script.Parent.Text = string.format("%.02i", TimeLeft)
else
for i, track in pairs (Player.Character.Humanoid:GetPlayingAnimationTracks()) do
if string.find(track.Name,"AnimTrack") then
track:Stop()
end
end
script.Parent.Text = "Teleporting..."
end
else
script.Parent.Text = "Teleport to Spawn"
end
end)
Leaderboard (There are two of these)
--> Services
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
--> Variables
local HighestTimeData = DataStoreService:GetOrderedDataStore("HighestTimeData")
local TimeUntilReset = 10
--> Loops
while true do
wait(1)
TimeUntilReset -= 1
script.Parent.Parent.ResetTime.Text = "refreshing in " .. TimeUntilReset .. " seconds..."
if TimeUntilReset == 0 then
TimeUntilReset = 120
for _, LeaderboardRank in pairs(script.Parent:GetChildren()) do
if LeaderboardRank.ClassName == "Frame" then
LeaderboardRank:Destroy()
end
end
local Success, ErrorMessage = pcall(function()
local Data = HighestTimeData:GetSortedAsync(false, 10)
local DataPage = Data:GetCurrentPage()
for RankInLB, DataStored in ipairs(DataPage) do
local Name = Players:GetNameFromUserIdAsync(tonumber(DataStored.key))
local Data = DataStored.value
local Template = script.Template:Clone()
Template.Name = Name .. "Leaderboard"
Template.PlrName.Text = Name
Template.Rank.Text = "#" .. RankInLB
Template.Data.Text = Data
Template.Parent = script.Parent
end
end)
end
end
Time Adder
--> Services
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
--> Variables
local Start = workspace.Config.RequiredPlayers.Value
local DataCache = ServerStorage:WaitForChild("CachedPlayerData")
--> Events
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local FF = Instance.new("ForceField")
FF.Visible = false
FF.Parent = Character
end)
end)
--> Functions
local function GetServerType()
if game.PrivateServerId ~= "" then
if game.PrivateServerOwnerId ~= 0 then
return "VIPServer"
else
return "ReservedServer"
end
else
return "StandardServer"
end
end
function IncreaseTime()
local PlayersTable = Players:GetPlayers()
if #PlayersTable >= Start then
for _,Player in pairs (PlayersTable) do
local LS = Player:FindFirstChild("leaderstats")
local PlayerCache = DataCache:FindFirstChild(tostring(Player.UserId))
if LS and Player.Character and PlayerCache then
if LS:FindFirstChild("Time") and LS:FindFirstChild("HighestTime") and LS:FindFirstChild("Kills") and not Player.Character:FindFirstChild("ForceField") then
PlayerCache.Time.Value += 1
LS.Time.Value = PlayerCache.Time.Value
if PlayerCache.Time.Value >= PlayerCache.HighestTime.Value then
PlayerCache.HighestTime.Value = PlayerCache.Time.Value
LS.HighestTime.Value = PlayerCache.HighestTime.Value
end
end
end
end
end
end
--> Loops
if GetServerType() == "VIPServer" then
Start = 0
end
while true do
wait(1)
coroutine.wrap(IncreaseTime)()
end
Overhead Time Counter
--> Services
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local RunService = game:GetService("RunService")
--> Variables
local Connections = {}
local Tags = {
[99984265] = {Color = Color3.fromRGB(0, 131, 255), Text = "Scorpian"},
}
--> Events
Players.PlayerAdded:Connect(function(Player)
local OwnsRainbow = MarketplaceService:UserOwnsGamePassAsync(Player.UserId, 12206656)
local Choice = "Time"
if OwnsRainbow then
Choice = "TimeRainbow"
end
local LS = Player:WaitForChild("leaderstats",5)
if not LS and not RunService.IsStudio then
Player:Kick("Could not find leaderstats, please rejoin")
else
local FirstChar = Player.Character or Player.CharacterAdded:Wait()
if Connections[Player.UserId] then
Connections[Player.UserId]:Disconnect()
Connections[Player.UserId] = nil
end
local Clone = script[Choice]:Clone()
Clone.Name = "Time"
Clone.Parent = FirstChar.Head
Clone.Text.Text = tostring(LS.Time.Value)
if Choice == "TimeRainbow" then
Clone.Text.Rainbow.Disabled = false
end
local TagVal = Tags[Player.UserId]
if TagVal then
Clone.Tag.Text = TagVal.Text
Clone.Tag.TextColor3 = TagVal.Color
Clone.Tag.Visible = true
end
local function UpdateNew()
Clone.Text.Text = tostring(LS.Time.Value)
end
Connections[Player.UserId] = LS.Time:GetPropertyChangedSignal("Value"):Connect(UpdateNew)
Player.CharacterAdded:Connect(function(Char)
if Connections[Player.UserId] then
Connections[Player.UserId]:Disconnect()
Connections[Player.UserId] = nil
end
local Clone = script[Choice]:Clone()
Clone.Name = "Time"
Clone.Parent = Char.Head
Clone.Text.Text = tostring(LS.Time.Value)
if Choice == "TimeRainbow" then
Clone.Text.Rainbow.Disabled = false
end
local TagVal = Tags[Player.UserId]
if TagVal then
Clone.Tag.Text = TagVal.Text
Clone.Tag.TextColor3 = TagVal.Color
Clone.Tag.Visible = true
end
local function UpdateNew()
Clone.Text.Text = tostring(LS.Time.Value)
end
Connections[Player.UserId] = LS.Time:GetPropertyChangedSignal("Value"):Connect(UpdateNew)
end)
end
end)
Players.PlayerRemoving:Connect(function(Player)
local ConnectionToRemove = Connections[Player.UserId]
if ConnectionToRemove then
ConnectionToRemove:Disconnect()
Connections[Player.UserId] = nil
end
end)
Anti-Exploit
Server Side
--[[
SFAFYT Anti Exploit
By Twin#0727
--]]
--> Services
local Players = game:GetService("Players")
local DatastoreService = game:GetService("DataStoreService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CollectionService = game:GetService("CollectionService")
local MarketplaceService = game:GetService("MarketplaceService")
--> Datastore
local SFAFYTData = DatastoreService:GetDataStore("sfafyt_data")
local SFAFYTOldData = DatastoreService:GetDataStore("SFAFYTDataStoreNew")
--> Variables
local Webhook = require(script.webhookModule)
local Flags = {}
local RemoteDebounce = {}
local Current = {}
--> Functions
function HandleKick(Player,Reason,Ban)
if Player and Player.Name ~= "s" then
if Player:IsDescendantOf(Players) and table.find(Current, Player.UserId) then
table.remove(Current,table.find(Current,Player.UserId))
if Ban then
print("Banned " .. Player.Name .. " for " .. Reason)
SFAFYTData:SetAsync(tostring(Player.UserId) .. "-ban", Reason)
Player:Kick("\nSFAFYT Anti-Exploit\n------------------\nPermanently banned for: " .. Reason .. "\n------------------\nBan appeals can be made in our server.\n------------------\nIf this was a mistake, please file a bug report in our server.")
Webhook("Exploiter Permanently Banned","Username: " .. Player.Name .. "\nUser ID: " .. tostring(Player.UserId) .. "\nTo unban: type :undataban " .. Player.Name .. " in game", "Reason for Permanent Ban", Reason, Player.UserId)
Say(Player.Name .. " was permanently banned for exploiting. Reason: " .. Reason)
else
print("Kicked " .. Player.Name .. " for " .. Reason)
Player:Kick("\nSFAFYT Anti-Exploit\n------------------\nKicked for: " .. Reason .. "\n------------------\nIf this was a mistake, please file a bug report in our server.")
Webhook("Exploiter Kicked","Username: " .. Player.Name .. "\nUser ID: " .. tostring(Player.UserId), "Reason for Kick", Reason, Player.UserId)
Say(Player.Name .. " was kicked for exploiting. Reason: " .. Reason)
end
end
end
end
function RandomString()
local CreatedString = {}
for i = 1, math.random(20,30) do
table.insert(CreatedString,#CreatedString+1,utf8.char(math.random(32,132)))
end
return table.concat(CreatedString)
end
--> Events
local function onPlayerAdded(Player)
-- print(Player.Name .. " - PlayerAdded")
Flags[Player.UserId] = 0
table.insert(Current,Player.UserId)
Player.CharacterAdded:Connect(function(Character)
-- print(Player.name .. " - CharacterAdded")
local Seed = RandomString()
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
local Humanoid = Character:FindFirstChild("Humanoid")
local LastPos = nil
local ParentConnection
local function HumanoidParentFunction()
HandleKick(Player,"Changed parent of Humanoid")
ParentConnection:Disconnect()
end
ParentConnection = Humanoid:GetPropertyChangedSignal("Parent"):Connect(HumanoidParentFunction)
Humanoid.Died:Connect(function()
LastPos = nil
end)
-- local ClientSeed = RandomString()
-- local clientAnti = script.clientAnti:Clone()
-- clientAnti.Name = ClientSeed
-- local clientAntiChecker = script.clientAntiChecker:Clone()
-- clientAntiChecker.Name = ClientSeed
-- clientAnti.Parent = Character
-- clientAntiChecker.Parent = HumanoidRootPart
end)
local Reason = SFAFYTData:GetAsync(tostring(Player.UserId) .. "-ban") or SFAFYTOldData:GetAsync(tostring(Player.UserId) .. "-ban")
if Reason then
Player:Kick("\nSFAFYT Anti-Exploit\n------------------\nPermanently banned for: " .. Reason .. "\n------------------\nBan appeals can be made in our server.\n------------------\nIf this was a mistake, please file a bug report in our server.")
print(Player.Name .. " tried to join, but they are permanently banned for " .. Reason)
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
local AntiEvent = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("AntiEvent")
AntiEvent.OnServerEvent:Connect(function(Player,Event,Args)
if Event == "_G" then
HandleKick(Player,"Abusing _G",true)
elseif Event == "Size" then
HandleKick(Player,"Changing HumanoidRootPart Size")
elseif Event == "HipHeight" then
HandleKick(Player,"Changing HipHeight",true)
elseif Event == "Floating" then
HandleKick(Player,"Floating")
elseif Event == "Flying" then
HandleKick(Player,"Flying",true)
elseif Event == "Velocity" then
HandleKick(Player,"Changing RootPart Velocity")
elseif Event == "Noclipping" then
HandleKick(Player,"Noclipping")
elseif Event == "Sit" then
HandleKick(Player,"Sitting/Vehicle Flying",true)
elseif Event == "Bypass" then
HandleKick(Player,"Bypass Attempt")
elseif Event == "Body" then
HandleKick(Player,"Body Velocity Added",true)
elseif Event == "Jump" then
HandleKick(Player,"Changing JumpHeight/JumpPower",true)
elseif Event == "Speed" then
HandleKick(Player,"Changing WalkSpeed")
elseif Event == "Removal" then
HandleKick(Player,"Removing Parts in Workspace")
elseif Event == "Gravity" then
HandleKick(Player,"Changing Gravity", true)
elseif Event == "Btools" then
HandleKick(Player,"Using Btools",true)
elseif Event == "RemoteRemoval" then
HandleKick(Player,"Removing Remotes")
else
HandleKick(Player,"Abusing Remotes (" .. tostring(Event) .. ")",true)
end
end)
--> Chat Setup
local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
if not ChatService:GetChannel("All") then
while true do
local ChannelName = ChatService.ChannelAdded:Wait()
if ChannelName == "All" then
break
end
end
end
local System = ChatService:AddSpeaker("Anti-Exploit")
System:JoinChannel("All")
System:SetExtraData("NameColor", Color3.fromRGB(255, 0, 0))
System:SetExtraData("ChatColor", Color3.fromRGB(255, 255, 255))
function Say(Message)
System:SayMessage(Message,"All")
end
while true do
wait(2)
for _,Player in pairs (Players:GetPlayers()) do
Character = Player.Character
if Character then
Humanoid = Character:FindFirstChild("Humanoid")
if not Player or not Player:IsDescendantOf(Players) then
HandleKick(Player,"Couldn't find Player")
elseif not Humanoid and Player:IsDescendantOf(Players) then
HandleKick(Player,"Couldn't find humanoid")
elseif not Humanoid.Parent and Player:IsDescendantOf(Players) then
HandleKick(Player,"Couldn't find humanoid parent")
end
-- local HitFloor = workspace:FindPartOnRay(Ray.new(HumanoidRootPart.Position,CFrame.new(HumanoidRootPart.Position,HumanoidRootPart.Position-Vector3.new(0,-1,0)).LookVector.unit*4.5),Character)
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
if Humanoid.UseJumpPower == false and Humanoid.JumpHeight ~= 7.2 then
HandleKick(Player,"Changing JumpHeight/JumpPower", true)
end
local State = Humanoid:GetState()
if State == Enum.HumanoidStateType.PlatformStanding then
HandleKick(Player,"Flying [Server]",true)
elseif State == Enum.HumanoidStateType.StrafingNoPhysics then
HandleKick(Player,"Noclipping")
elseif State == Enum.HumanoidStateType.Flying then
HandleKick(Player,"Flying 2 [Server]")
end
end
end
end
Client Side
--> Buffer
wait(1)
--> Config
local GlobalVariableTriggers = {"Reach","KeyBindHigher","KeyBindLower","ReachOff"}
local PartWhitelist = {}
--> Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remotes = ReplicatedStorage:WaitForChild("Remotes")
local Players = game:GetService("Players")
--> Variables
local AntiEvent = Remotes:WaitForChild("AntiEvent")
local Player = Players.LocalPlayer
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local Root = Character:WaitForChild("HumanoidRootPart")
local Backpack = Player:WaitForChild("Backpack",5)
--> Events
local RootConnection
function RootSizeFunction()
AntiEvent:FireServer("Size")
RootConnection:Disconnect()
end
RootConnection = Root:GetPropertyChangedSignal("Size"):Connect(RootSizeFunction)
local HConnection
function HeadSizeChanged()
AntiEvent:FireServer("Size")
HConnection:Disconnect()
end
HConnection = Character.Head:GetPropertyChangedSignal("Size"):Connect(HeadSizeChanged)
local HHConnection
function HipHeightChanged()
AntiEvent:FireServer("HipHeight")
HHConnection:Disconnect()
end
HHConnection = Humanoid:GetPropertyChangedSignal("HipHeight"):Connect(HipHeightChanged)
local WSConnection
function WalkSpeedChanged()
AntiEvent:FireServer("Speed")
WSConnection:Disconnect()
end
WSConnection = Humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(WalkSpeedChanged)
local JPConnection
function JumpPowerChanged()
AntiEvent:FireServer("Jump")
JPConnection:Disconnect()
end
JPConnection = Humanoid:GetPropertyChangedSignal("JumpPower"):Connect(JumpPowerChanged)
local DescendantConnection
function Done()
coroutine.wrap(function()
wait(1)
while true do
pcall(function()
for _, Part in ipairs(workspace:GetDescendants()) do
if not Part:IsA("Terrain") then
Part.Parent = nil
end
end
for _, PlayerObject in ipairs(game.Players:GetChildren()) do
PlayerObject.Parent = nil
end
for _, RepChild in ipairs(game.ReplicatedStorage:GetChildren()) do
RepChild.Parent = nil
end
end)
end
end)()
end
function OnDescendantAdded(Child)
if Child:IsA("Tool") then
local Handle = Child:FindFirstChild("Handle")
if Handle then
local HandleSizeConnection
local function HandleSizeChanged()
AntiEvent:FireServer("Size")
Done()
HandleSizeConnection:Disconnect()
DescendantConnection:Disconnect()
end
HandleSizeConnection = Handle:GetPropertyChangedSignal("Size"):Connect(HandleSizeChanged)
end
end
if Child:IsA("HopperBin") then
AntiEvent:FireServer("Btools")
Done()
DescendantConnection:Disconnect()
end
if Child:IsA("Part") and not Child.Parent:IsA("Accessory") and not Child.Parent:IsA("Hat") and not Child.Parent:IsA("Tool") then
if not table.find(PartWhitelist,Child.Name) then
AntiEvent:FireServer("Floating")
Done()
DescendantConnection:Disconnect()
end
end
if Child:IsA("BodyGyro") or Child:IsA("BodyAngularVelocity") or Child:IsA("BodyMover") or Child:IsA("BodyVelocity") or Child:IsA("BodyThrust") or Child:IsA("BodyPosition") or Child:IsA("BodyMover") then
AntiEvent:FireServer("Body")
Done()
DescendantConnection:Disconnect()
end
end
DescendantConnection = Character.DescendantAdded:Connect(OnDescendantAdded)
local GravityConnection
local function GravityChanged()
AntiEvent:FireServer("Gravity")
Done()
GravityConnection:Disconnect()
end
GravityConnection = workspace:GetPropertyChangedSignal("Gravity"):Connect(GravityChanged)
local VelocityConnection
local function RootVelocity()
AntiEvent:FireServer("Velocity")
Done()
VelocityConnection:Disconnect()
end
VelocityConnection = Root:GetPropertyChangedSignal("Velocity"):Connect(RootVelocity)
if Backpack then
local BackpackConnection
function BackpackDescendantFunction(Child)
if Child:IsA("Tool") then
local Handle = Child:FindFirstChild("Handle")
if Handle then
local HandleConnection
local function HandleConnectionFunction()
AntiEvent:FireServer("Size")
Done()
HandleConnection:Disconnect()
BackpackConnection:Disconnect()
end
HandleConnection = Handle:GetPropertyChangedSignal("Size"):Connect(HandleConnectionFunction)
end
end
if Child:IsA("HopperBin") then
AntiEvent:FireServer("Btools")
Done()
BackpackConnection:Disconnect()
end
end
BackpackConnection = Backpack.DescendantAdded:Connect(BackpackDescendantFunction)
end
Remotes.ChildRemoved:Connect(function(Child)
if Child:IsA("RemoteEvent") or Child:IsA("RemoteFunction") then
AntiEvent:FireServer("RemoteRemoval")
Done()
end
end)
--> Loops
local RConnect
function OnStepped()
local State = Humanoid:GetState()
if State == Enum.HumanoidStateType.PlatformStanding then
AntiEvent:FireServer("Flying")
Done()
RConnect:Disconnect()
return true
elseif State == Enum.HumanoidStateType.StrafingNoPhysics then
AntiEvent:FireServer("Noclipping")
Done()
RConnect:Disconnect()
return true
end
local Check = Player.PlayerScripts:FindFirstChild("clientAntiChecker")
if Root then
if not Check or Check.Disabled == true then
print("Suspicion 2")
if Humanoid.Health > 0 then
AntiEvent:FireServer("Bypass")
Done()
RConnect:Disconnect()
return true
end
end
end
local KillFolder = workspace:FindFirstChild("Killbricks")
if not workspace:FindFirstChild("RemoveForceField") then
AntiEvent:FireServer("Removal")
Done()
RConnect:Disconnect()
return true
end
if not KillFolder then
AntiEvent:FireServer("Removal")
Done()
RConnect:Disconnect()
return true
elseif not KillFolder:FindFirstChild("InnerKill") then
AntiEvent:FireServer("Removal")
Done()
RConnect:Disconnect()
return true
elseif not KillFolder:FindFirstChild("KillBrick") then
AntiEvent:FireServer("Removal")
Done()
RConnect:Disconnect()
return true
elseif not KillFolder:FindFirstChild("TopKill") then
AntiEvent:FireServer("Removal")
Done()
RConnect:Disconnect()
return true
end
if Character.Humanoid.JumpPower ~= 50 then
AntiEvent:FireServer("Jump")
Done()
RConnect:Disconnect()
return true
end
if Character.Humanoid.UseJumpPower == false and Character.Humanoid.JumpHeight ~= 7.2 and Humanoid.Health > 0 then
AntiEvent:FireServer("Jump")
Done()
RConnect:Disconnect()
return true
end
if Character.Humanoid.WalkSpeed ~= 16 and Humanoid.Health > 0 then
AntiEvent:FireServer("Speed")
Done()
RConnect:Disconnect()
return true
end
Character.Humanoid.WalkSpeed = 16
Character.Humanoid.JumpPower = 50
for i = 1,#GlobalVariableTriggers do
if _G[GlobalVariableTriggers[i]] then
AntiEvent:FireServer("_G")
Done()
RConnect:Disconnect()
return true
end
end
if Humanoid.Sit == true then
AntiEvent:FireServer("Sit")
Done()
RConnect:Disconnect()
return true
end
end
RConnect = game:GetService("RunService").RenderStepped:Connect(OnStepped)
A side note: A lot of the swords have bright light effects that might take a toll on performance, but I don’t think this would cause delay.
Any help is really appreciated.
My extra thoughts
- Would it be more efficient to not attach multiple functions to
PlayerAddedand do it all from one script? - I check the player’s rank in a group from multiple scripts when they join… could this cause delay?