Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

i cant save a player data. how to fix?

i try to save a player userid whenever a player try to exploiting, so i can store his id at datastore

local data = game:GetService("DataStoreService")
local banList = data:GetDataStore("banList")
game.Players.PlayerAdded:Connect(function(player)
	local userid = player.UserId
	player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild("HumanoidRootPart")
		humanoid.ChildAdded:Connect(function(object)
			if object.ClassName == "BodyGyro" or object.ClassName == "BodyPosition" or object.ClassName == "BodyVelocity" then
				object:Destroy()
				local success, errormessage = pcall(function()
					banList:SetAsync(userid, true)
				end)
				if success then
					print("Ban saved!")
				end
				player:Kick("Jangan Ngecit Dongg !!")
			end
		end)
	end)
end)

and this is the different script i have

local DataStoreService = game:GetService("DataStoreService")
local banList = DataStoreService:GetDataStore("banList")
local manual = {}
game.Players.PlayerAdded:Connect(function(player)

	local userid = player.UserId
	if manual[userid] then
		player:Kick("KEBAN KAU ANJIM !!")
	end
	local banned
	local success, errormessage = pcall(function()
		banned = banList:GetAsync(userid)
	end)
	if banned == true then
		player:Kick("KEBAN KAU ANJIM !!")
		print("Mamamm")
	end
end)

but this script is not working, how do i fix it what is wrong with the script?

1 comment

0

Exploits work on the client ONLY. You cannot see if a player inserts something unless you're using a local script.

1 answer

✓ Accepted answer

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.

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        local userid = player.UserId

1 comment

0

I just made a mistake of the explanation here, you can have codes before CharacterAdded but you cannot have any codes between PlayerAdded and CharacterAdded.

This discussion is preserved as it was. New answers, comments, and votes are closed.