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: Random hat spawn

Previous Thread :: Next Thread 
AceTacticalEye is not online. AceTacticalEye
Joined: 07 Feb 2016
Total Posts: 88
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
AceTacticalEye is not online. AceTacticalEye
Joined: 07 Feb 2016
Total Posts: 88
04 Jun 2016 03:41 AM
And that it also removes your current hat :)


169 (RAP)
Report Abuse
iJacobness is not online. iJacobness
Joined: 20 Jan 2014
Total Posts: 4944
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
AceTacticalEye is not online. AceTacticalEye
Joined: 07 Feb 2016
Total Posts: 88
06 Jun 2016 09:20 AM
Gonna try it right now :)
Report Abuse
AceTacticalEye is not online. AceTacticalEye
Joined: 07 Feb 2016
Total Posts: 88
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 is not online. 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
AceTacticalEye is not online. AceTacticalEye
Joined: 07 Feb 2016
Total Posts: 88
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
AceTacticalEye is not online. AceTacticalEye
Joined: 07 Feb 2016
Total Posts: 88
06 Jun 2016 09:35 AM
ugh, it still doesn't work
Report Abuse
AceTacticalEye is not online. AceTacticalEye
Joined: 07 Feb 2016
Total Posts: 88
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
iJacobness is not online. iJacobness
Joined: 20 Jan 2014
Total Posts: 4944
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
AceTacticalEye is not online. AceTacticalEye
Joined: 07 Feb 2016
Total Posts: 88
09 Jun 2016 09:19 AM
it works, but if you die and you respawn you don't get hats anymore
Report Abuse
Televincent is not online. Televincent
Joined: 20 Nov 2013
Total Posts: 394
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 is not online. cgjnm
Joined: 22 Dec 2011
Total Posts: 2347
09 Jun 2016 10:33 AM
Use a .CharacterAdded() event
Report Abuse
Vezious is not online. 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
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