i try to save a player userid whenever a player try to exploiting, so i can store his id at datastore
01 | local data = game:GetService( "DataStoreService" ) |
02 | local banList = data:GetDataStore( "banList" ) |
03 | game.Players.PlayerAdded:Connect( function (player) |
04 | local userid = player.UserId |
05 | player.CharacterAdded:Connect( function (character) |
06 | local humanoid = character:WaitForChild( "HumanoidRootPart" ) |
07 | humanoid.ChildAdded:Connect( function (object) |
08 | if object.ClassName = = "BodyGyro" or object.ClassName = = "BodyPosition" or object.ClassName = = "BodyVelocity" then |
09 | object:Destroy() |
10 | local success, errormessage = pcall ( function () |
11 | banList:SetAsync(userid, true ) |
12 | end ) |
13 | if success then |
14 | print ( "Ban saved!" ) |
15 | end |
16 | player:Kick( "Jangan Ngecit Dongg !!" ) |
17 | end |
18 | end ) |
19 | end ) |
20 | end ) |
and this is the different script i have
01 | local DataStoreService = game:GetService( "DataStoreService" ) |
02 | local banList = DataStoreService:GetDataStore( "banList" ) |
03 | local manual = { } |
04 | game.Players.PlayerAdded:Connect( function (player) |
05 |
06 | local userid = player.UserId |
07 | if manual [ userid ] then |
08 | player:Kick( "KEBAN KAU ANJIM !!" ) |
09 | end |
10 | local banned |
11 | local success, errormessage = pcall ( function () |
12 | banned = banList:GetAsync(userid) |
13 | end ) |
14 | if banned = = true then |
15 | player:Kick( "KEBAN KAU ANJIM !!" ) |
16 | print ( "Mamamm" ) |
17 | end |
18 | end ) |
but this script is not working, how do i fix it what is wrong with the script?
As a comment said, exploits work on the client only but I can still explain it for you.
You seem to be making manual bans and detection bans, make sure these scripts are a Script
, not LocalScript
or it won't work since LocalScripts can't access DataStores. If you sure they are a Script
, don't make any codes before CharacterAdded
or nothing will run after that line since CharacterAdded
fires immediately once the character is added to Workspace
and you should make it like this.
1 | game.Players.PlayerAdded:Connect( function (player) |
2 | player.CharacterAdded:Connect( function (character) |
3 | local userid = player.UserId |