|
| 11 May 2016 06:23 PM |
I'm really new to this.. I'm tryin to make so when player on start their hats get auto removed Script
" script.Parent:GetChildren() for i=1, #d do if (d[i].className == "Hat") then d[i]:remove() " I just can't get it to work...
|
|
|
| Report Abuse |
|
|
|
| 11 May 2016 06:24 PM |
d = script.Parent:GetChildren() for i=1, #d do if (d[i].className == "Hat") then d[i]:remove() |
|
|
| Report Abuse |
|
|
| |
|
|
| 11 May 2016 06:27 PM |
d = script.Parent:GetChildren() for i=1, #d do if (d[i].className == "Hat") then d[i]:remove() end end |
|
|
| Report Abuse |
|
|
|
| 11 May 2016 06:30 PM |
Nope Thanks for tryin i'll just see if i can pay someone to help me fix it...
|
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 11 May 2016 06:31 PM |
| how are you using the script |
|
|
| Report Abuse |
|
|
|
| 11 May 2016 06:32 PM |
game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(char) for i,v in pairs(char:GetChildren() do if v:IsA"Hat" then v:Destroy() end end end) end)
tell me if it works |
|
|
| Report Abuse |
|
|
|
| 11 May 2016 06:33 PM |
Grrr still spawning with my hats....
|
|
|
| Report Abuse |
|
|
|
| 11 May 2016 06:34 PM |
smal mistake forgot a paranthesis
game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(char) for i,v in pairs(char:GetChildren()) do if v:IsA"Hat" then v:Destroy() end end end) end) |
|
|
| Report Abuse |
|
|
lululukas
|
  |
| Joined: 23 Aug 2010 |
| Total Posts: 1043 |
|
|
| 11 May 2016 06:35 PM |
^ he was just correcting your code which doesn't even make sense, it's you that messed up and gave misleading info
put this in starterplayerscripts (local script)
me=game.Players.LocalPlayer repeat wait() until me.Character for i,v in pairs(me.Character:GetChildren()) do if v:IsA"Hat" then v:Destroy() end end |
|
|
| Report Abuse |
|
|
|
| 11 May 2016 06:37 PM |
Chill bro.. Like i said i'm a big noob at this.. lol
|
|
|
| Report Abuse |
|
|
|
| 11 May 2016 06:37 PM |
| Get outta here. That dont work either |
|
|
| Report Abuse |
|
|
|
| 11 May 2016 06:38 PM |
Shadow make that a script in workspace or serverscriptstorage.
not lcoalscript |
|
|
| Report Abuse |
|
|
| |
|
lululukas
|
  |
| Joined: 23 Aug 2010 |
| Total Posts: 1043 |
|
|
| 11 May 2016 06:39 PM |
@TheCoder
Sorry I wasn't referring to you, I was referring to OP, your post wasn't made before i started writing the reply
Also why wouldn't that work? seems perfectly fine to me. |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 11 May 2016 06:42 PM |
local Players = game:GetService("Players") local Debris = game:GetService("Debris") local PlayerAdded, CharacterAdded, HatHandler, Spawn
function PlayerAdded(player) Spawn(CharacterAdded, player.Character or player.CharacterAdded:wait()) player.CharacterAdded:connect(CharacterAdded) end
function CharacterAdded(character) for _, obj in ipairs(character:GetChildren()) do Spawn(HatHandler, obj) end character.ChildAdded:connect(HatHandler) end
function HatHandler(obj) if obj:IsA("Hat") then Debris:AddItem(obj,0) end end
function Spawn(func, ...) local args={...} spawn(function() func(unpack(args)) end) end
for _, player in ipairs(Players:GetPlayers()) do Spawn(PlayerAdded, player) end
Players.PlayerAdded:connect(PlayerAdded) |
|
|
| Report Abuse |
|
|
|
| 11 May 2016 06:43 PM |
Thanks but still not working its prob me doing it wrong..
|
|
|
| Report Abuse |
|
|
|
| 11 May 2016 06:43 PM |
cause hats take a little to load.
In CharacterAdded its already loaded. iirc |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 11 May 2016 06:45 PM |
| @Shadow Make sure you are not using ServerStorage, place my code in a normal script inside of ServerScriptService. |
|
|
| Report Abuse |
|
|
|
| 11 May 2016 06:46 PM |
Wow thanks @Casualist and The Coder It worked.. if you need currency give me a shout i'll hook you up with something. ;)
|
|
|
| Report Abuse |
|
|
lululukas
|
  |
| Joined: 23 Aug 2010 |
| Total Posts: 1043 |
|
|
| 11 May 2016 06:46 PM |
@Casual
Why overcomplicate it like that? |
|
|
| Report Abuse |
|
|
|
| 11 May 2016 06:49 PM |
Well I need a graphic art for my game. Are you a graphic artist? or..? |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 11 May 2016 06:49 PM |
| Because OP was having problems getting anyone's code to work. So I just made it almost foolproof. That works as a normal script, as a local script, if you append it to the bottom of existing code (i.e. code with waits, so if it runs late and a player(s) is already in game that player's hats get removed still). |
|
|
| Report Abuse |
|
|