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.
local player = game.Players.LocalPlayer
local chara = player.Character
while not chara do
wait()
chara = player.Character
end
local function OnClicked ()
local cash = player.Money.Value
if cash >= script.Parent.Parent.Price.Value then
cash = cash - script.Parent.Parent.Price.Value
local Morph = script.Parent.Parent.morph
local BodyParts = chara:GetChildren()
for i,b in pairs(BodyParts) do
if (b.className == "Humanoid") then
end
wait(0.1)
end
BodyParts = chara:GetChildren()
for i,b in pairs(BodyParts) do
if (b.className == "CharacterMesh") or (b.className == "Hat") or (b.className == "Shirt") or (b.className == "Pants") or (b.className == "ShirtGraphic") then
b:Destroy()
end
if (b.className == "Part") then
if (b.Name == "Head") then
if (b:findFirstChild("Mesh") ~= nil) then
b.Mesh:Destroy()
end
end
end
wait(0.1)
end
BodyParts = Morph:GetChildren()
for i,b in pairs(BodyParts) do
if (b.className == "CharacterMesh") or (b.className == "Shirt") or (b.className == "Pants") or (b.className == "ShirtGraphic") then
b:Clone().Parent = chara
end
if (b.className == "Part") then
if (b.Name == "Head") then
if (b:findFirstChild("Mesh") ~= nil) then
b.Mesh:Clone().Parent = chara.Head
end
end
end
wait(0.1)
end
else return end
end
script.Parent.MouseButton1Click: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
