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 » Game Design
Home Search
 

Re: [SH] Cloning Hats Error

Previous Thread :: Next Thread 
georgeba is not online. georgeba
Joined: 29 Oct 2011
Total Posts: 1092
21 Aug 2015 03:03 PM
I have a model in lighting with multiple CSG Hats. The line where it says local Hats = game.Lighting.Hats:GetChildren() doesn't work but it does work when it is like: local Hats = game.Lighting.Hats.TopHat

Why is this?

function onPlayerEntered(newPlayer)
wait(3)
local Hats = game.Lighting.Hats:GetChildren()
local HatsClone = Hats:Clone()
HatsClone.Parent = newPlayer.Character
HatsClone.Anchored = false
local w = Instance.new("ManualWeld")
w.Parent = newPlayer.Character
w.Part0 = HatsClone
w.Part1 = newPlayer.Character.Head
w.C0 = CFrame.new(0, -.8, 0)*CFrame.new(0,0, 0)
end

game.Players.PlayerAdded:connect(onPlayerEntered)
Report Abuse
litalela is not online. litalela
Joined: 30 Mar 2010
Total Posts: 6267
21 Aug 2015 03:09 PM
you want to clone all the hats? um ok if hats your thing

-- store in server storage scrub
game.Players.PlayerAdded:connect(function(newPlayer)
player.CharacterAdded:connect(function(char)
wait(3)
local hats = game.ServerStorage.Hats:GetChildren()
for i =1, #hats do
local HatsClone = hats[i]:Clone()
HatsClone.Parent = newPlayer.Character
HatsClone.Anchored = false
local w = Instance.new("ManualWeld", char)
w.Parent = char
w.Part0 = HatsClone
w.Part1 = char.Head
w.C0 = CFrame.new(0, -.8, 0)*CFrame.new(0,0, 0)
end
end)
end)


Bʀᴏ ᴅᴏ ʏᴏᴜ ᴇᴠᴇɴ Lᴜᴀ?
Report Abuse
georgeba is not online. georgeba
Joined: 29 Oct 2011
Total Posts: 1092
21 Aug 2015 03:11 PM
Wow! Thanks SO MUCH
Report Abuse
litalela is not online. litalela
Joined: 30 Mar 2010
Total Posts: 6267
21 Aug 2015 03:12 PM
mhm any time

Bʀᴏ ᴅᴏ ʏᴏᴜ ᴇᴠᴇɴ Lᴜᴀ?
Report Abuse
georgeba is not online. georgeba
Joined: 29 Oct 2011
Total Posts: 1092
21 Aug 2015 03:18 PM
Last question...
Let's say my layout is like this
-ServerStorage
--Hats
---Sunglasses Model
----Parts

Like, if one of my hats was inside a model what would I change?
Report Abuse
litalela is not online. litalela
Joined: 30 Mar 2010
Total Posts: 6267
21 Aug 2015 03:22 PM
huh? elaborate

Bʀᴏ ᴅᴏ ʏᴏᴜ ᴇᴠᴇɴ Lᴜᴀ?
Report Abuse
georgeba is not online. georgeba
Joined: 29 Oct 2011
Total Posts: 1092
21 Aug 2015 03:23 PM
So some of my hats have multiple parts, and so I had to group them. Right now when I put the group into the model Hats they don't clone to the player
Report Abuse
litalela is not online. litalela
Joined: 30 Mar 2010
Total Posts: 6267
21 Aug 2015 03:25 PM
-- store in server storage scrub
game.Players.PlayerAdded:connect(function(newPlayer)
player.CharacterAdded:connect(function(char)
wait(3)
local hats = game.ServerStorage.Hats:GetChildren()
for i =1, #hats do
if not hats[i]:IsA"Model" then
local HatsClone = hats[i]:Clone()
HatsClone.Parent = newPlayer.Character
HatsClone.Anchored = false
local w = Instance.new("ManualWeld", char)
w.Parent = char
w.Part0 = HatsClone
w.Part1 = char.Head
w.C0 = CFrame.new(0, -.8, 0)*CFrame.new(0,0, 0)
else
for _, v in pairs(hats[i]:GetChildren()) do
local HatsClone = v:Clone()
HatsClone.Parent = newPlayer.Character
HatsClone.Anchored = false
local w = Instance.new("ManualWeld", char)
w.Parent = char
w.Part0 = HatsClone
w.Part1 = char.Head
w.C0 = CFrame.new(0, -.8, 0)*CFrame.new(0,0, 0)
end
end
end
end)
end)

Bʀᴏ ᴅᴏ ʏᴏᴜ ᴇᴠᴇɴ Lᴜᴀ?
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
21 Aug 2015 03:26 PM
Maybe use hat instances? There is a reason they are there.
Report Abuse
litalela is not online. litalela
Joined: 30 Mar 2010
Total Posts: 6267
21 Aug 2015 03:26 PM
yeah use hat instances, far better but w/e floats your boat

Bʀᴏ ᴅᴏ ʏᴏᴜ ᴇᴠᴇɴ Lᴜᴀ?
Report Abuse
georgeba is not online. georgeba
Joined: 29 Oct 2011
Total Posts: 1092
21 Aug 2015 03:26 PM
No no, for what I'm doing I need to use this. I want the user to not be able to drop it
Report Abuse
litalela is not online. litalela
Joined: 30 Mar 2010
Total Posts: 6267
21 Aug 2015 03:28 PM
w/e did my script work?

Bʀᴏ ᴅᴏ ʏᴏᴜ ᴇᴠᴇɴ Lᴜᴀ?
Report Abuse
georgeba is not online. georgeba
Joined: 29 Oct 2011
Total Posts: 1092
21 Aug 2015 03:29 PM
Testing
Report Abuse
georgeba is not online. georgeba
Joined: 29 Oct 2011
Total Posts: 1092
21 Aug 2015 03:29 PM
Yeah, Thanks you so much!
Report Abuse
litalela is not online. litalela
Joined: 30 Mar 2010
Total Posts: 6267
21 Aug 2015 03:30 PM
mhm any time

Bʀᴏ ᴅᴏ ʏᴏᴜ ᴇᴠᴇɴ Lᴜᴀ?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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