|
| 04 Jun 2016 03:40 AM |
Does anyone knows a script where you can insert a lot of hat ids and you spawn with a random one?
169 |
|
|
| Report Abuse |
|
|
|
| 04 Jun 2016 03:41 AM |
And that it also removes your current hat :)
169 (RAP) |
|
|
| Report Abuse |
|
|
|
| 04 Jun 2016 04:49 AM |
local id_list = {} --add ids to this so its like {123456,654321} local player = AceTacticalEye math.randomseed(os.time()) random = math.random(1,#id_list) local hat = game:GetService("InsertService"):LoadAsset(id_list[random]):GetChildren()[1] for i,v in pairs(game.Players[player].Character:GetChildren()) do if v:IsA('Hat') then v:Destroy() end end hat.Parent = game.Players[player].Character
r+://393244197r+://393244224r+://393244262 |
|
|
| Report Abuse |
|
|
| |
|
|
| 06 Jun 2016 09:31 AM |
| hmm, it seems not to work. do i have to change local player = AceTacticalEye to local player = game.Players...? |
|
|
| Report Abuse |
|
|
MezornoIV
|
  |
| Joined: 20 Jul 2010 |
| Total Posts: 2276 |
|
|
| 06 Jun 2016 09:32 AM |
Make local player
local player = game.Players.LocalPlayer --(gets the local player, very easy) |
|
|
| Report Abuse |
|
|
|
| 06 Jun 2016 09:33 AM |
This is the error i get
16:34:57.847 - Workspace.Script:6: bad argument #2 to '?' (string expected, got nil) |
|
|
| Report Abuse |
|
|
|
| 06 Jun 2016 09:35 AM |
| ugh, it still doesn't work |
|
|
| Report Abuse |
|
|
|
| 06 Jun 2016 09:36 AM |
This is the full script im using:
local id_list = {31101391,64444871,21070012,96103379,48545806,138932314,250395631,162067148} local player = game.Players.LocalPlayer math.randomseed(os.time()) random = math.random(1,#id_list) local hat = game:GetService("InsertService"):LoadAsset(id_list[random]):GetChildren()[1] for i,v in pairs(game.Players[player].Character:GetChildren()) do if v:IsA('Hat') then v:Destroy() end end hat.Parent = game.Players[player].Character |
|
|
| Report Abuse |
|
|
|
| 06 Jun 2016 12:44 PM |
local id_list = {31101391,64444871,21070012,96103379,48545806,138932314,250395631,162067148} math.randomseed(os.time()) r = math.random(1,#id_list) local hat = game:GetService("InsertService"):LoadAsset(id_list[r]):GetChildren()[1] for i,v in pairs(game.Players.LocalPlayer.Character:GetChildren()) do if v:IsA('Hat') then v:Destroy() end hat.Parent = game.Players.LocalPlayer.Character end
r+://393244197r+://393244224r+://393244262 |
|
|
| Report Abuse |
|
|
|
| 09 Jun 2016 09:19 AM |
| it works, but if you die and you respawn you don't get hats anymore |
|
|
| Report Abuse |
|
|
|
| 09 Jun 2016 10:11 AM |
Since I'm only a beginner at scripting, I can't guarantee this'll work but try making it so that the game detects if the player is alive so that they add the hat again after you die. Again, I'm not very experienced at scripting so I dunno if this'll work. :p
Scelerisque lac. |
|
|
| Report Abuse |
|
|
cgjnm
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
|
| 09 Jun 2016 10:33 AM |
| Use a .CharacterAdded() event |
|
|
| Report Abuse |
|
|
Vezious
|
  |
| Joined: 09 Nov 2013 |
| Total Posts: 606 |
|
|
| 09 Jun 2016 10:50 AM |
Yes, use CharacterAdded.
P.S., by the looks of it, it looks like they gave you local scripts, so while this works in Studio, it will not in game with FilteringEnabled. |
|
|
| Report Abuse |
|
|