Okay so I have a well, let me show you script..
local Banned = game.Workspace.Banned.Value local p = game.Players.LocalPlayer function Banned() if p.Name == Banned then local Ban = game.ServerStorage.BanCode:Clone() p.Backpack.Switch:Destroy() p.Backpack.dETONATE:Destroy() p.Backpack["sPEED UP"]:Destroy() p.Backpack["Slow down"]:Destroy() Ban.Parent = p.Backpack end end game.Players.PlayerAdded:connect(Banned)
It won't remove the stuff or the clone After solved I will ask another for my BanCode script
Is this in a LocalScript or a normal Script? If it's a LocalScript, your problem is-
game.Players.PlayerAdded:connect(Banned)
If it's a Script, your problem is-
local p = game.Players.LocalPlayer
You've overridden the variable "Banned" with a function. Differ the Names between the function Banned() and the StringValue
local Bannedlist = game.Workspace.Banned.Value local p = game.Players.LocalPlayer function Banned() if p.Name == Bannedlist then local Ban = game.ServerStorage.BanCode:Clone() p.Backpack.Switch:Destroy() p.Backpack.dETONATE:Destroy() p.Backpack["sPEED UP"]:Destroy() p.Backpack["Slow down"]:Destroy() Ban.Parent = p.Backpack end end game.Players.PlayerAdded:connect(Banned)
Make sure you're checking if the Backpack has those items, before calling Destroy on them.
For example, you should be at the least be doing:
if p.Backpack:FindFirstChild(Switch) then p.Backpack:FindFirstChild(Switch):Destroy() end
Another improvement maybe on your bannedlist, for as it stands now you can only ban one player.
I would have a check like this done:
Bannedlist = ","..Bannedlist.."," if string.find(Bannedlist,","..p.Name..",") then -- you code end
I add these commas just to ensure that you're not punishing someone who's name is ABC123, when you've actually banned ABC1234 - the string.find will still say it sees ABC123 in the list, so by adding a comma to the beginning and end, string.find can reliably look for an exact match.
Just a suggestion... Plus I'm not sure about adding the ban code to the Backpack - I would probably parent it to the player Character object instead, but if that works - great.