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: Accessory Script

Previous Thread :: Next Thread 
omgninja1 is not online. omgninja1
Joined: 15 Feb 2012
Total Posts: 95
27 Jun 2017 08:43 AM
Is their something that will only allow a character to have a max of [3] accessories on?
(Will Pay)


Report Abuse
omgninja1 is not online. omgninja1
Joined: 15 Feb 2012
Total Posts: 95
27 Jun 2017 08:43 AM
There*


Report Abuse
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
27 Jun 2017 08:55 AM
You can easily make them.

local numAccessories = 0
game.Players.PlayerAdded:connect(function (player)
repeat wait() until player.Character ~= nil
player.CharacterAdded:connect(function (character)
for _, v in pairs(character:GetChildren()) do
if v:IsA("Accessory") then
numAccessories = numAccessories + 1
end
end
if numAccessories > 3 then
for _, v in pairs(character:GetChildren()) do
if _ > 3 then
if v:IsA("Accessory") then
v:Destroy()
end
end
end
end
end)
end)

I don't know if this works or if this is as efficient, but this is what I came up with on the spot.

Report Abuse
Milenveliki is not online. Milenveliki
Joined: 14 Aug 2013
Total Posts: 1097
27 Jun 2017 09:36 AM
local function b(v)
if v.className=='Accessory'then wait()v:destroy()end
end
local function a(char)wait(.6)
char.ChildAdded:connect(b)
end
Game:service'Players'.PlayerAdded:connect(function(plr)
local char=plr.Character;if char then a(char)end
plr.CharacterAdded:connect(a)
end)
Report Abuse
Milenveliki is not online. Milenveliki
Joined: 14 Aug 2013
Total Posts: 1097
27 Jun 2017 09:39 AM
local function b(v) if v.className=='Accessory'then wait() local c=0;for i,v in ipairs(v.Parent:children())do if v.className=='Accessory'then ######### end if c>3 then v:destroy()end;end end local function a(char)wait(.6) char.ChildAdded:connect(b) end Game:service'Players'.PlayerAdded:connect(function(plr) local char=plr.Character;if char then a(char)end plr.CharacterAdded:connect(a) end)
Report Abuse
Milenveliki is not online. Milenveliki
Joined: 14 Aug 2013
Total Posts: 1097
27 Jun 2017 09:40 AM
local function b(v)
if v.className=='Accessory'then wait()
local count=0;for i,v in ipairs(v.Parent:children())do
if v.className=='Accessory'then count=count+1;end
end
if c>3 then v:destroy()end;end
end
local function a(char)wait(.6)
char.ChildAdded:connect(b)
end
Game:service'Players'.PlayerAdded:connect(function(plr)
local char=plr.Character;if char then a(char)end
plr.CharacterAdded:connect(a)
end)
Report Abuse
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
27 Jun 2017 09:41 AM
That'll destroy every accessory...
Report Abuse
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
27 Jun 2017 09:41 AM
Nvm, didn't see newest posts
Report Abuse
omgninja1 is not online. omgninja1
Joined: 15 Feb 2012
Total Posts: 95
27 Jun 2017 10:32 AM
I want everything removed if you have more than 3 hats+Accessories in total


Report Abuse
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
27 Jun 2017 10:33 AM
local numAccessories = 0
game.Players.PlayerAdded:connect(function (player)
repeat wait() until player.Character ~= nil
player.CharacterAdded:connect(function (character)
for _, v in pairs(character:GetChildren()) do
if v:IsA("Accessory") then
numAccessories = numAccessories + 1
end
end
if numAccessories > 3 then
for _, v in pairs(character:GetChildren()) do
if v:IsA("Accessory") then
v:Destroy()
end
end
end
end)
end)
Report Abuse
Milenveliki is not online. Milenveliki
Joined: 14 Aug 2013
Total Posts: 1097
27 Jun 2017 10:35 AM
local function b(v)
if v.className=='Accessory'or v.className=='Hat'then wait()
local count=0;for i,v in ipairs(v.Parent:children())do
if v.className=='Accessory'or v.className=='Hat'then count=count+1;end
end
if count>3 then
for i,v in ipairs(v.Parent:children())do
if v.className=='Accessory'or v.className=='Hat'then v:destroy()end
end
end;end
end
local function a(char)wait(.6)
char.ChildAdded:connect(b)
end
Game:service'Players'.PlayerAdded:connect(function(plr)
local char=plr.Character;if char then a(char)end
plr.CharacterAdded:connect(a)
end)
Report Abuse
omgninja1 is not online. omgninja1
Joined: 15 Feb 2012
Total Posts: 95
27 Jun 2017 04:39 PM
bump


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