i rewrote my admin commands script as it is still not working but

now i dont have errors kinda

if I place it on StarterCharacterScripts with a LocalScript it says "Datastore cant be accessed from client"

The Script:

--//Admin Commands Script
--//Variables\\--

local admins = {"RedLecko434", "RedLoL7u7", "franchun04"}
local Prefix = "."
local DataStore = game:GetService("DataStoreService")
local BanList = DataStore:GetDataStore("Banlist")

--//Events\\--

game.Players.PlayerAdded:Connect(function()
	local Folder = Instance.new("Folder", Player)
	Folder.Name = "PlayerValues"
	
	local BanCheck = Instance.new("BoolValue", Folder)
	BanCheck.Name = "IsBanned"
	BanCheck.Value = BanList:GetAsync(Player.userId) or false
	if Player.PlayerValues.IsBanned.Value == true then
		Player:Kick("You're Banned From This Game By An Admin")
	end
	
	Player.Chatted:connect(function(message)
		for i, AdminName in ipairs(Admins) do
			if Player.Name == AdminName then
				--//Commands\\--
				--//Kill
				if message:sub(1, 6) == (Prefix.. "kill ")then
					game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent"):FireServer()
					local TargetPlayer = game.Players:FindFirstChild(message:sub(7))
					if TargetPlayer then
						local Character = TargetPlayer.Character
						if Character then
							Character.Humanoid.Health = 0
						end
					end
				end
				--//Heal
				if message:sub(1, 6) == (Prefix.. "heal ")then
					game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent"):FireServer()
					local TargetPlayer = game.Players:FindFirstChild(message:sub(7))
					if TargetPlayer then
						local Character = TargetPlayer.Character
						if Character then
							Character.Humanoid.Health = 100
						end
					end
				end
				--kick
				if message:sub(1, 6) == "kick " then
					game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent"):FireServer()
					local TargetPlayer = game.Players:FindFirstChild(message:sub(7))
					if TargetPlayer then
						TargetPlayer:Kick("You Have Been Kicked By " .. Playername)
					end
				end
				--//Ban Command
				if message:sub(1, 5) == "ban " then
					game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent"):FireServer()
					local TargetPlayer = game.Players:FindFirstChild(message:sub(6))
					if TargetPlayer then
						local BanCheck = TargetPlayer.PlayerValues.IsBanned
						if BanCheck then
							BanCheck.Value = true
							BanList:SetAsync(TargetPlayer.userId, true)
						end
						TargetPlayer:Kick("You've been banned by " .. Player.Name) --//Reason || Message
					end
				end
				
				--//Unban Command
				if message:sub(1, 7) == "unban " then --//USES ID NOT NAME
					game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent"):FireServer()
					local UserId = tonumber(message:sub(8))
					if UserId then
						BanList:SetAsync(UserId, false)
					end
				end
				--StarGl
				if message:sub(1, 6) == "glit " then
					game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent"):FireServer()
					local TargetPlayer = game.Players:FindFirstChild(message:sub(7))
					if TargetPlayer then
						game.ServerStorage.sg:GetChildren(TargetPlayer)
						print("DAB!!!1!")
					end
				end
				break
			end
		end
	end)
end)

-- If you can keep these lines I would apreciate it, thanks

Good Luck Also all "Player" are marked with Blue

5 comments

0

I dont know what you're wanting us to do. The error speaks for itself.

0

Im sorry, but scripting is not my thing. i dont know where the error is.

0

So you took this script and you dont know how to use it, and you want us to fix it?

0

No, im saying that i dont understand that much, and i dont know where the problem is.

0

A local script accesses the client, per the error datastores cant be accessed from the client.