Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Won't delete nor clone?

Asked by 9 years ago

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

3 answers

Log in to vote
0
Answered by 9 years ago

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
0
I changed it to script, removed localplayer and added p in function, still does nothing fireboltofdeath 635 — 9y
0
You're checking if the player's name is equal to Banned? grasheeno 70 — 9y
0
Yes fireboltofdeath 635 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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)



0
K fireboltofdeath 635 — 9y
0
It still won't work? fireboltofdeath 635 — 9y
0
I'm out for ideas then:/ randomsmileyface 375 — 9y
Log in to vote
0
Answered by 9 years ago

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.

Answer this question