Why is my morph script not inserting the charactermeshes?
Asked by
6 years ago Edited 6 years ago
Hi, i want to make a script that morphs someone when they clicked a button. The script is in a local script under starter gui.
01 | local player = game.Players.LocalPlayer |
02 | local chara = player.Character |
05 | chara = player.Character |
08 | local function OnClicked () |
09 | local cash = player.Money.Value |
10 | if cash > = script.Parent.Parent.Price.Value then |
11 | cash = cash - script.Parent.Parent.Price.Value |
14 | local Morph = script.Parent.Parent.morph |
15 | local BodyParts = chara:GetChildren() |
16 | for i,b in pairs (BodyParts) do |
17 | if (b.className = = "Humanoid" ) then |
22 | BodyParts = chara:GetChildren() |
23 | for i,b in pairs (BodyParts) do |
24 | if (b.className = = "CharacterMesh" ) or (b.className = = "Hat" ) or (b.className = = "Shirt" ) or (b.className = = "Pants" ) or (b.className = = "ShirtGraphic" ) then |
27 | if (b.className = = "Part" ) then |
28 | if (b.Name = = "Head" ) then |
29 | if (b:findFirstChild( "Mesh" ) ~ = nil ) then |
37 | BodyParts = Morph:GetChildren() |
38 | for i,b in pairs (BodyParts) do |
39 | if (b.className = = "CharacterMesh" ) or (b.className = = "Shirt" ) or (b.className = = "Pants" ) or (b.className = = "ShirtGraphic" ) then |
40 | b:Clone().Parent = chara |
42 | if (b.className = = "Part" ) then |
43 | if (b.Name = = "Head" ) then |
44 | if (b:findFirstChild( "Mesh" ) ~ = nil ) then |
45 | b.Mesh:Clone().Parent = chara.Head |
58 | script.Parent.MouseButton 1 Click:Connect(OnClicked) |
The script deletes all clothes on the character and spawns the head mesh, but
somehow it doesnt put the charactermeshes in the character.
There is no error output either. Hope someone can help me