Artic’s Anti-Fly [R15 Characters]
Hello everyone so as I said today before this thread today I was working on my Artic’s Anti-Fly Script. I tested it out and works pretty well I could say but I want everyone of you to review it again so let’s get started. Here is the main script. There is also some parts of code that I’ll use in next update. I also like to have scripts to look a little more complicated, so please don’t bully me for any of those reasons.
The download of model is here
Here are some snips of whole code…
Main Script:
--Put this script in ServerScriptService please okay?
local Module = require(script:FindFirstChild("Average"):WaitForChild("ModuleScript"))
local MaxY = 20 --IMPORTANT: Change this to maximum Y position of your game because it's always different!! (This should work on normal BasePlate)
local MaxBoolCaughts = 3 -- Chnage this to how many times you allow player to do mistake before adding a score to script counter
local MaxCounter = 4 -- Change this to maximum counter (caughts)
--Don't change these if you are not sure what you are doing
--Basically you have number from 0 to 1 higher to 1 number is player will have to be more correct
local AvreageDifference = 0.60
local AverageBoolAndGameTime = 0.50
game.Players.PlayerAdded:Connect(function(Player)
local ValueS = Instance.new("IntValue")
local BoolCounter = Instance.new('IntValue')
local BoolTurnedOFF = Instance.new('IntValue')
local Yaxis = Instance.new("IntValue")
local InGameTime = Instance.new('IntValue')
local BoolValueS = Instance.new('BoolValue')
ValueS.Parent = script
ValueS.Name = Player.Name
BoolValueS.Parent = ValueS
BoolValueS.Name = "RestrictedArea"
BoolCounter.Parent = BoolValueS
BoolCounter.Name = "Time"
BoolTurnedOFF.Parent = BoolValueS
BoolTurnedOFF.Name = "TurnedOFF"
InGameTime.Parent = BoolValueS
InGameTime.Name = "TimeInGame"
Yaxis.Parent = BoolValueS
Yaxis.Name = "Y"
Player.CharacterAdded:Connect(function(Character)
local function WeldToHuman(A,B)
B.CFrame = A.CFrame
local Weld = Instance.new("Weld")
Weld.Part0 = A
Weld.C0 = A.CFrame:Inverse()
Weld.Part1 = B
Weld.C1 = B.CFrame:Inverse()
Weld.Parent = A
return Weld
end
WeldToHuman(Character:FindFirstChild("HumanoidRootPart"),Instance.new("Part",Player))
Player:WaitForChild("Part").Transparency = 1
Player:WaitForChild("Part").Locked = true
while true do
wait(1)
local function YaxisExists()
if Character:FindFirstChild('HumanoidRootPart') ~= nil then
local Yaxis = Character:FindFirstChild('HumanoidRootPart').Position.Y
return Yaxis
end
return false
end
local success, message = pcall(YaxisExists)
Yaxis.Value = message
script:FindFirstChild("Average").Value = tonumber(Module.Average(0,0,0))
while BoolValueS.Value == false do
script:FindFirstChild("Average").Value = tonumber(Module.Average(0,0,0))
local success, message = pcall(YaxisExists)
wait(1)
InGameTime.Value = InGameTime.Value + 1
BoolTurnedOFF.Value = BoolTurnedOFF.Value + 1
if success ~= false then
if message > MaxY then
if BoolValueS.Value ~= true or BoolValueS.Value ~= false then
BoolValueS.Value = true
if ValueS.Value > MaxCounter then
if BoolCounter.Value/InGameTime.Value < AverageBoolAndGameTime then
local avg = script.Average.Value
if avg/message < AvreageDifference then
if script[Player.Name] ~= nil then
script[Player.Name]:Destroy()
warn('Player: '.. Player.Name .. ' was caught exploiting')
Player:Kick("We caught you exploiting")
--Add here things to happen once player is kicked or in PlayerRemoving function
end
end
end
end
end
end
end
end
while BoolValueS.Value == true do
script:FindFirstChild("Average").Value = tonumber(Module.Average(0,0,0))
local success, message = pcall(YaxisExists)
wait(1)
InGameTime.Value = InGameTime.Value + 1
BoolCounter.Value = BoolCounter.Value + 1
if BoolCounter.Value > MaxBoolCaughts then
ValueS.Value = ValueS.Value + 1
BoolCounter.Value = 0
wait(1)
end
if message < MaxY then
BoolValueS.Value = false
end
if success ~= false then
if message > MaxY then
if BoolValueS.Value ~= true or BoolValueS.Value ~= false then
BoolValueS.Value = true
if ValueS.Value > MaxCounter then
if BoolCounter.Value/InGameTime.Value < AverageBoolAndGameTime then
local avg = script.Average.Value
if avg/message < AvreageDifference then
if script[Player.Name] ~= nil then
script[Player.Name]:Destroy()
warn('Player: '.. Player.Name .. ' was caught exploiting')
Player:Kick("We caught you exploiting")
--Add here things to happen once player is kicked or in PlayerRemoving function
end
end
end
end
end
end
end
end
end
end)
end)
ModuleScript to get all in game AverageValue of Y axises:
--Literally nothing to change here trust me :D
local module = {}
module.Average = function(a,b,c)
local Players = game.Players:GetChildren()
for i=1,#Players do
if game.ServerScriptService:FindFirstChild("Artic's Anti-Fly"):FindFirstChild(tostring(Players[i])) ~= nil then
local Y = game.ServerScriptService:FindFirstChild("Artic's Anti-Fly"):FindFirstChild(tostring(Players[i])):FindFirstChild("RestrictedArea"):FindFirstChild("Y").Value
a = a + tonumber(Y)
c = #Players
end
end
return a/c
end
return module
PROOF that this Artic's Anti-Fly Script works
Make sure to turn on the Server Side view in Roblox Studio to see those values!
IMPORTANT
Make sure to open Main Script and change settings only if you are using this model for your game. If you are using this on normal baseplate map this default settings in script should work.
I mean if there is anything that could of been better feel free to reply, I will appreciate help if there is any. Even thought if you want to test this anti fly script feel free to get it for free in roblox market, link is written above at the beggining and don’t forget to add script inside ServerScriptService. I hope you have an amazing day today!