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: Can't make NPC wear hat?

Previous Thread :: Next Thread 
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
07 Aug 2015 06:21 PM
Filtering Enabled is on, but when it isn't it works...

My snippet of code:
local function updatehair()
for i,v in pairs(characterModel.Character:GetChildren()) do
if v.className=="Hat" then v:Destroy() end
end

local model=game.Lighting.HairObjects:FindFirstChild(tostring(hair)):Clone()
model.Handle.Position=characterModel.Character.Head.Position
model.Handle.Locked=true
model.Parent=characterModel.Character
model.Handle.Anchored=false
model.Handle.BrickColor=BrickColor.new(colors[haircolor])
model.Name="Hair"
end

My whole code:

local colors = {"Br. yellowish green";"Bright yellow";"Bright orange";"Bright red";"Bright violet";"Bright blue";"Bright bluish green";"Bright green";"Institutional white";"White";"Light stone grey";"Mid gray";"Medium stone grey";"Dark stone grey";"Black";"Really black";"Grime";"Br. yellowish orange";"Light orange";"Sand red";"Lavender";"Sand blue";"Medium blue";"Sand green";"Brick yellow";"Cool yellow";"Neon orange";"Medium red";"Light reddish violet";"Pastel Blue";"Teal";"Medium green";"Pastel brown";"Pastel yellow";"Pastel orange";"Pink";"Pastel violet";"Pastel light blue";"Pastel blue-green";"Pastel green";"Olive";"New Yeller";"Neon orange";"Really red";"Hot pink";"Really blue";"Toothpaste";"Lime green";"Brown";"Nougat";"Dark orange";"Royal purple";"Alder";"Cyan";"Light blue";"Camo";"Reddish brown";"CGA brown";"Dusty Rose";"Magenta";"Deep blue";"Navy blue";"Dark green";"Earth green";
}
wait(2)

local facebolt=1
local head=1
local metal=1
local torso=1
local tip=1
local hair=1
local haircolor=1
local launcher=1


local Frame=script.Parent:WaitForChild("Frame")
local p=game.Players.LocalPlayer
local c=p.Character or p.CharacterAdded:wait()
local Stats=p:WaitForChild("Stats")
local cam=game.Workspace.CurrentCamera

cam:ClearAllChildren()

local characterModel=game.ReplicatedStorage.CharacterModel:Clone()
characterModel.Parent=game.Workspace
cam.CameraType=Enum.CameraType.Scriptable
cam.CoordinateFrame=CFrame.new(characterModel.Character.Torso.Position)*CFrame.new(0,0,10)

mainp = characterModel.Character.Torso
mainp:BreakJoints()

for i,v in pairs(characterModel.Character:children()) do
if (v:IsA("BasePart") or v:IsA("VehicleSeat")) and v ~= mainp then
v:BreakJoints()
local w = Instance.new("Motor",v)
w.Part0 = mainp
w.Part1 = v
w.C0 = mainp.CFrame:toObjectSpace(v.CFrame)
v.Anchored = false
end
end

--[[function weld()
local parts,last = {}
local function scan(parent)
for _,v in pairs(parent:GetChildren()) do
if (v:IsA("BasePart")) then
if (last) then
local w = Instance.new("Weld")
w.Name = ("%s_Weld"):format(v.Name)
w.Part0,w.Part1 = last,v
w.C0 = last.CFrame:inverse()
w.C1 = v.CFrame:inverse()
w.Parent = last
end
last = v
table.insert(parts,v)
end
scan(v)
end
end
scan(characterModel.Character)
for _,v in pairs(parts) do
if v.Name~="Torso"then
v.Anchored = false
end
end
end

weld()]]

local function CheckId(p1,id)
if p1.Handle.Mesh.MeshId==id then return true else return false end
end
local function updatehair()
for i,v in pairs(characterModel.Character:GetChildren()) do
if v.className=="Hat" then v:Destroy() end
end

local model=game.Lighting.HairObjects:FindFirstChild(tostring(hair)):Clone()
model.Handle.Position=characterModel.Character.Head.Position
model.Handle.Locked=true
model.Parent=characterModel.Character
model.Handle.Anchored=false
model.Handle.BrickColor=BrickColor.new(colors[haircolor])
model.Name="Hair"
end
local function update()
if not characterModel.Character:FindFirstChild("Hair") then updatehair() end

print("Character Cleared")
--Set the variables
if facebolt<1 then facebolt=#colors end
if facebolt>#colors then facebolt=1 end
if head<1 then head=#colors end
if head>#colors then head=1 end
if metal<1 then metal=#colors end
if metal>#colors then metal=1 end
if torso>#colors then torso=1 end
if torso<1 then torso=#colors end
if tip<1 then tip=#colors end
if tip>#colors then tip=1 end
if hair<1 then hair=11 end
if hair>11 then hair=1 end
if haircolor<1 then haircolor=#colors end
if haircolor>#colors then haircolor=1 end
if launcher<1 then launcher=#colors end
if launcher>#colors then launcher=1 end
--hair



local bey=characterModel.Bey
bey.FaceBolt.BrickColor=BrickColor.new(colors[facebolt])
bey.Head.BrickColor=BrickColor.new(colors[head])
bey.Metal.BrickColor=BrickColor.new(colors[metal])
bey.Torso.BrickColor=BrickColor.new(colors[torso])
bey.Tip.BrickColor=BrickColor.new(colors[tip])
for i,v in pairs(characterModel.Launcher:GetChildren()) do
v.BrickColor=BrickColor.new(colors[launcher])
end
end

update()


for i,v in pairs(Frame:GetChildren()) do
if v:FindFirstChild("Left") and v:FindFirstChild("Right") then
v.Left.MouseButton1Down:connect(function()
if v.Name=="Facebolt" then facebolt=facebolt+1 end
if v.Name=="Hair" then hair=hair+1 update() updatehair()end
if v.Name=="Hair_Color" then haircolor=haircolor+1 update() updatehair()end
if v.Name=="Head" then head=head+1 end
if v.Name=="Metal" then metal=metal+1 end
if v.Name=="Tip" then tip=tip+1 end
if v.Name=="Torso" then torso=torso+1 end
if v.Name=="Launcher_Color" then launcher=launcher+1 end
update()
end)

v.Right.MouseButton1Down:connect(function()
if v.Name=="Facebolt" then facebolt=facebolt-1 end
if v.Name=="Hair" then hair=hair-1 update() updatehair()end
if v.Name=="Hair_Color" then haircolor=haircolor-1 update() updatehair()end
if v.Name=="Head" then head=head-1 end
if v.Name=="Metal" then metal=metal-1 end
if v.Name=="Tip" then tip=tip-1 end
if v.Name=="Torso" then torso=torso-1 end
if v.Name=="Launcher_Color" then launcher=launcher-1 end
update()
end)
end
end

Frame:WaitForChild("Finish").MouseButton1Down:connect(function()
local stats
end)


The problem is that, once the hat is cloned, it falls. No weld is automatically created...
Report Abuse
BothAngles is not online. BothAngles
Joined: 01 Dec 2011
Total Posts: 9604
07 Aug 2015 06:32 PM
the character needs a rootpart i think
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
07 Aug 2015 06:32 PM
why does it work with fe off...
Report Abuse
BothAngles is not online. BothAngles
Joined: 01 Dec 2011
Total Posts: 9604
07 Aug 2015 06:33 PM
idk did u try it
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
07 Aug 2015 06:35 PM
something is obv not being replicated.


"Talk is cheap. Show me the code." - Linus Torvalds
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
07 Aug 2015 06:36 PM
It's not obvious to me >.<

What is it
Report Abuse
BothAngles is not online. BothAngles
Joined: 01 Dec 2011
Total Posts: 9604
07 Aug 2015 06:39 PM
try using the drooling zombie as the model
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
07 Aug 2015 06:43 PM
Didn't work. Tried on my character also.
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
07 Aug 2015 06:54 PM
bump
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
07 Aug 2015 06:57 PM
You realize you can use BrickColor.Random() instead of making a table filled with all the colors right
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
07 Aug 2015 06:57 PM
This is a character creation thingy.
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
07 Aug 2015 08:32 PM
Bump, am I done for?
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
08 Aug 2015 09:41 AM
Tried on an actual character.

Didn't work.

FilteringEnabled if off and it's parent is Camera.
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
08 Aug 2015 09:43 AM
It works when it's parented to Workspace.
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
08 Aug 2015 10:11 AM
bump
Report Abuse
ScripterTony is not online. ScripterTony
Joined: 26 Nov 2012
Total Posts: 5257
08 Aug 2015 10:20 AM
In your game, it appears that the hat position is in front of the character head
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
08 Aug 2015 10:33 AM
Position doesn't matter, bump.
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
08 Aug 2015 11:24 AM
ogm
Report Abuse
PixilatedPanda is not online. PixilatedPanda
Joined: 24 May 2012
Total Posts: 33
08 Aug 2015 12:06 PM
I have no idea what you just said.
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
08 Aug 2015 12:17 PM
>The problem is that, once the hat is cloned, it falls. No weld is automatically created.
Report Abuse
Queststrong is not online. Queststrong
Joined: 10 Aug 2010
Total Posts: 1085
08 Aug 2015 12:43 PM
Programs-->Delete System 32
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
08 Aug 2015 12:49 PM
ok
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
08 Aug 2015 01:57 PM
This makes no sense!
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
08 Aug 2015 05:20 PM
bumpo
Report Abuse
IllogicalGames is not online. IllogicalGames
Joined: 28 Feb 2014
Total Posts: 7609
08 Aug 2015 05:23 PM
say /e weld
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