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

I cannot remove myself from datastore of banned players?

local circle = script.Parent
local players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local bannedStore = DataStoreService:GetDataStore("BannedPlayers")

local function getBan(player)
	if bannedStore:GetAsync(player.UserId) then
		return true	end
	return false
end


local function checkBan(player)
	if getBan(player) then
		player:Kick("Please do not come back as you failed.")
	end
end

local function CircleExtending()
	circle.Size += Vector3.new(0,5,5)
end

local function CircleShrinking(player)
	circle.Size -= Vector3.new(0,50,50)
	bannedStore:SetAsync(player.UserId, true)
	player:Kick("You have failed this event, thank you for attending.")
end

local function onPlayerAdded(player)
	player.CharacterAdded:Connect(function ()
		CircleExtending()
		checkBan(player)
	end)
	player.CharacterRemoving:Connect(function ()
		CircleShrinking(player)
	end)
	player.PlayerRemoving:Connect(function ()
		CircleShrinking(player)
	end)
end

players.PlayerAdded:Connect(onPlayerAdded)

I try running bannedStore:RemoveAsync(my id) but it says 'attempt to index nil' I know it can't be nil because It kicks me when I join, my friend is also banned and I cannot remove him too

2 comments

0

That's some screwed power your code has!

0

Ah... well, either you do SetAsync(id, false) or just change it by a datastore plugin. Or delete the script..

1 answer

This function seems to be banning and kicking everyone regardless.

local function CircleShrinking(player)
	circle.Size -= Vector3.new(0,50,50)
	bannedStore:SetAsync(player.UserId, true) --Ban
	player:Kick("You have failed this event, thank you for attending.") --Kick
end

You call this function whenever a client's character is removed or when the player leaves the game effectively banning everyone after their first play of your game. Change this to stop everyone from being banned

player.CharacterRemoving:Connect(function ()
	CircleShrinking(player)
end)
player.PlayerRemoving:Connect(function ()
	CircleShrinking(player)
end)

For unbanning yourself and your friends I recommend using :RemoveAsync() or doing a manual :SetAsync(UserId,false)

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