so im making a anticheat script inside of a folder that holds all the exploiters names
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Ban = require(ReplicatedStorage.ModuleScripts.Commands.Ban)
local AntiCheatStrikes = ServerStorage.PlayerList.AntiCheatStrikes
AntiCheatStrikes.ChildAdded:Connect(function(v)
print("value added")
if v:IsA("IntValue") then
local exploiter = v.Name
v:GetPropertyChangedSignal("Value"):Connect(function()
print(v.Value)
if v.Value >= 20 then
local Banned = Players:FindFirstChild(exploiter).UserId
Ban.Function(Banned,"Banned for exploiting")
end
end)
end
end)
the problem is when i add a new value something is suppose to print but it dosnt
this is how the value is created and changed
HungerTimer.Count:Connect(function(timeelapsed)
local currenttime = math.floor(timeelapsed + 0.5)
if currenttime == 15 then
print("timer ended resetting..")
HungerTimer:Reset()
HungerTimer:Start()
if AntiCheatStrikes:FindFirstChild(player.Name) then
local Strike = AntiCheatStrikes[player.Name]
Strike.Value += 1
else
local Strike = Instance.new("IntValue")
Strike.Name = player.Name
Strike.Value = 1
Strike.Parent = AntiCheatStrikes
end
end
end)
the function is apart of a module that i got from a plugin
function Timer:Start() -- Begins a timer
self.StartTime = tick()
self.LastStep = self.StartTime
self.Countdown = runS.Heartbeat:Connect(function()
local currentTime = tick()-self.StartTime
if self.CountStep then
if tick()-self.LastStep >= self.CountStep then
self.CountEvent:Fire(currentTime) -- return current time
self.LastStep = self.LastStep+self.CountStep
end
end
if currentTime >= self.Duration then
-- fire event, cancel timer
self.IsRunning = false
self.CompletedEvent:Fire(currentTime)
self:Stop()
end
end)
end
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local HungerDrain = ReplicatedStorage.RemoteEvents.HungerDrain
local TimerModule = require(ReplicatedStorage.ModuleScripts.Timer)
local AntiCheatStrikes = ServerStorage.PlayerList.AntiCheatStrikes
Players.PlayerAdded:Connect(function(player) -- real hunger system
local HungerTimer = TimerModule.new(16)
player.CharacterAdded:Connect(function(character)
HungerTimer:Start()
local hunger = player:WaitForChild("NonPvPStats").Hunger
local Human = character.Humanoid
while true do
wait(12.5)
if hunger.Value > 0 then
hunger.Value = hunger.Value - 3
elseif hunger.Value == 0 then
hunger.Value = 0
Human.Health = Human.Health - 10
end
end
end)
HungerDrain.OnServerEvent:Connect(function(player,value) -- fake hungers system
HungerTimer:Reset()
HungerTimer:Start()
if value ~= 3 then
if AntiCheatStrikes:FindFirstChild(player.Name) then
local Strike = AntiCheatStrikes[player.Name]
Strike.Value += 1
else
local Strike = Instance.new("IntValue")
Strike.Name = player.Name
Strike.Value = 1
Strike.Parent = AntiCheatStrikes
end
else
return -- innocent
end
end)
HungerTimer.Count:Connect(function(timeelapsed)
local currenttime = math.floor(timeelapsed + 0.5)
if currenttime == 15 then
print("timer ended resetting..")
HungerTimer:Reset()
HungerTimer:Start()
if AntiCheatStrikes:FindFirstChild(player.Name) then
print("strike increased")
local Strike = AntiCheatStrikes[player.Name]
Strike.Value += 1
else
print("strike added")
local Strike = Instance.new("IntValue")
Strike.Name = player.Name
Strike.Value = 1
Strike.Parent = AntiCheatStrikes
end
end
end)
end)
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Ban = require(ReplicatedStorage.ModuleScripts.Commands.Ban)
local AntiCheatStrikes = ServerStorage.PlayerList.AntiCheatStrikes
AntiCheatStrikes.ChildAdded:Connect(function(v)
print("value added")
if v:IsA("IntValue") then
local exploiter = v.Name
v:GetPropertyChangedSignal("Value"):Connect(function()
print(v.Value)
if v.Value >= 20 then
local Banned = Players:FindFirstChild(exploiter).UserId
Ban.Function(Banned,"Banned for exploiting")
end
end)
end
end)
i figuired out the problem it was pretty simple lol
so scripts dont run if they are under server storage
so all i had to do was move my script from that to serverscriptservice