generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Ban hat script

Previous Thread :: Next Thread 
THEjokertoxic is not online. THEjokertoxic
Joined: 08 Feb 2012
Total Posts: 622
03 Dec 2016 03:27 PM
I was flipping through the catalog to see if I could find a script that allows one to ban a certain hat (speed wings ugh) from a place, I was not able to find one however. Does anyone have a script, or a link to a script on the catalog that could help with this?
Report Abuse
PurelyMystic is not online. PurelyMystic
Joined: 24 May 2010
Total Posts: 931
03 Dec 2016 03:28 PM
A for i,v in pairs when a player character is added and check if the name matches for any
Report Abuse
Bit_blox is not online. Bit_blox
Joined: 28 Aug 2016
Total Posts: 974
03 Dec 2016 03:31 PM
hold on


#code print("Game Point!")
Report Abuse
Bit_blox is not online. Bit_blox
Joined: 28 Aug 2016
Total Posts: 974
03 Dec 2016 03:55 PM
I'm pretty sure this should fix your problem

local bannedhats = {'Gargoyle Wings','Bat Wings'}
game.Players.PlayerAdded:connect(function()
repeat wait() until game.Players.LocalPlayer.Character
if game.Players.LocalPlayer.Character.bannedhats then
game.Players.LocalPlayer.Character.bannedhats:Destroy()
end
end)


#code print("Game Point!")
Report Abuse
cabbler is not online. cabbler
Joined: 19 Jun 2015
Total Posts: 735
03 Dec 2016 04:03 PM
local id = 262669756 --catalog ID of hat

local hatModel = game:GetService('InsertService'):LoadAsset(tostring(id))
local hat

local function removeHat(char)
local player = game.Players:GetPlayerFromCharacter(char)
if char and player then
repeat wait(); hat = hatModel:GetChildren()[1]
until char and player:HasAppearanceLoaded() and hat
for i,v in pairs(char:GetChildren()) do
if v.Name == hat.Name then
v:Destroy()
end
end
end
end

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(removeHat)
end)

for i,v in pairs(game.Players:GetPlayers()) do
spawn(function() removeHat(v.Character) end)
end
Report Abuse
i_Ja is not online. i_Ja
Joined: 06 Apr 2014
Total Posts: 9297
03 Dec 2016 04:04 PM
local BannedHats = {"Name here", "Name here"}

game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
for _,v in pairs(Character:GetChildren()) do
if v:IsA("Hat") then
if BannedHats[v.Name] then
v:Destroy()
end
end
end
end)
end)

~Add 5k+ Posts~ {Previous Names: ContentCrown, i_Movie, SurfaceLight}
Report Abuse
THEjokertoxic is not online. THEjokertoxic
Joined: 08 Feb 2012
Total Posts: 622
03 Dec 2016 04:05 PM
Hey thanks guys, that should help!
Report Abuse
i_Ja is not online. i_Ja
Joined: 06 Apr 2014
Total Posts: 9297
03 Dec 2016 04:08 PM
First one isn't right, second one is probably correct, although it has a bunch of stuff that's not even needed.

Mine is the more efficient way imo.

~Add 5k+ Posts~ {Previous Names: ContentCrown, i_Movie, SurfaceLight}
Report Abuse
Bit_blox is not online. Bit_blox
Joined: 28 Aug 2016
Total Posts: 974
03 Dec 2016 04:09 PM
at least i tried to help.

-_-


#code print("Game Point!")
Report Abuse
i_Ja is not online. i_Ja
Joined: 06 Apr 2014
Total Posts: 9297
03 Dec 2016 04:11 PM
Bit, you forgot to read from the table. xD But it's ok, wasn't judgin. I don't even know if mine works yet.

~Add 5k+ Posts~ {Previous Names: ContentCrown, i_Movie, SurfaceLight}
Report Abuse
Bit_blox is not online. Bit_blox
Joined: 28 Aug 2016
Total Posts: 974
03 Dec 2016 04:11 PM
wdym read from the table? ive never heard of that before


#code print("Game Point!")
Report Abuse
cabbler is not online. cabbler
Joined: 19 Jun 2015
Total Posts: 735
03 Dec 2016 04:14 PM
iJa's script won't work because 1. ingame names are different from catalog names. 2. you don't wait until the character loads. 3. :IsA('Hat') probably won't work.
Report Abuse
i_Ja is not online. i_Ja
Joined: 06 Apr 2014
Total Posts: 9297
03 Dec 2016 04:15 PM
lol.. You basically did this.

if game.Players.LocalPlayer[BannedHats] then
game.Players.LocalPlayer[BannedHats]:Destroy()
end

With your method you should do this:

for _,v in pairs(Character:GetChildren()) do
if v:FindFirstChild(BannedHats[1]) or v:FindFirstChild(BannedHats[2]) then
v:Destroy()
end
end



~Add 5k+ Posts~ {Previous Names: ContentCrown, i_Movie, SurfaceLight}
Report Abuse
i_Ja is not online. i_Ja
Joined: 06 Apr 2014
Total Posts: 9297
03 Dec 2016 04:16 PM
Cabbler, mine works. I've done plenty of character modifying in-game with the dev console.

if v:IsA("Hat") will work.

~Add 5k+ Posts~ {Previous Names: ContentCrown, i_Movie, SurfaceLight}
Report Abuse
cabbler is not online. cabbler
Joined: 19 Jun 2015
Total Posts: 735
03 Dec 2016 04:19 PM
Except I gave 3 solid reasons why it won't work, so saying it works without testing it doesn't change that. Mine works.

:IsA('Hat') doesn't work because most exist as accessories, not hats.

Don't misinform ppl.
Report Abuse
i_Ja is not online. i_Ja
Joined: 06 Apr 2014
Total Posts: 9297
03 Dec 2016 04:20 PM
Oh, I forgot all about accesories. *Face-palm* my bad.

~Add 5k+ Posts~ {Previous Names: ContentCrown, i_Movie, SurfaceLight}
Report Abuse
Bit_blox is not online. Bit_blox
Joined: 28 Aug 2016
Total Posts: 974
03 Dec 2016 04:21 PM
:IsA('Hat') or :IsA('Accessory') then





kmn


#code print("Game Point!")
Report Abuse
i_Ja is not online. i_Ja
Joined: 06 Apr 2014
Total Posts: 9297
03 Dec 2016 04:23 PM
Yeah, that would work then. But all hats are being transferred over to accessories right? So that means we're all going to have to use if v:IsA("Accessory) soon.

~Add 5k+ Posts~ {Previous Names: ContentCrown, i_Movie, SurfaceLight}
Report Abuse
cabbler is not online. cabbler
Joined: 19 Jun 2015
Total Posts: 735
03 Dec 2016 04:30 PM
great idea bit blox. also here is a version that works with multiple, and connects existing players to the function.

local ids = {1, 2, 3} --catalog IDs of hat

local hatModels={}
local hats={}
for i,v in pairs(ids) do
table.insert(hatModels, game:GetService('InsertService'):LoadAsset(tostring(v)))
end
for i,v in pairs(hatModels) do
repeat wait() until v:GetChildren()[1]
hats[v:GetChildren()[1].Name]=true
end

local function removeHat(char)
local player = game.Players:GetPlayerFromCharacter(char)
if char and player then
repeat wait() until player:HasAppearanceLoaded()
for i,v in pairs(char:GetChildren()) do
if ( v:IsA('Hat') or v:IsA('Accessory') ) and hats[v.Name] then
v:Destroy()
end
end
end
end

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(removeHat)
end)

for i,v in pairs(game.Players:GetPlayers()) do
spawn(function() removeHat(v.Character) end)
v.CharacterAdded:connect(removeHat)
end
Report Abuse
THEjokertoxic is not online. THEjokertoxic
Joined: 08 Feb 2012
Total Posts: 622
04 Dec 2016 11:24 AM
Thanks cabbler, that seemed to have done it.

If anyone else wants the script, here it is:

https://www.roblox.com/library/565428054/Ban-hat-script
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image