Hello. I hope this should be a quick fix. Here is my localscript:
local LegionFrame = script.Parent.Parent.Legions local UniformFrame = script.Parent.Parent.Uniforms local MorphsDir = game.ReplicatedStorage.Morphs local Libs =game.ReplicatedStorage.Libs local RemoteEvent = game.ReplicatedStorage.Youneedthis local Player = game.Players.LocalPlayer for i,v3 in pairs(MorphsDir:GetChildren()) do local Button = Instance.new("TextButton") Button.Size = UDim2.new(1,0,0,50) Button.BackgroundTransparency = 1 Button.Font = "SciFi" Button.TextSize = 30 Button.TextXAlignment = "Left" Button.TextColor3 = Color3.fromRGB(255,255,255) Button.Text = v3.name Button.Parent = LegionFrame Button.MouseButton1Click:Connect(function() for i,v2 in pairs(UniformFrame:GetChildren()) do if v2.ClassName == "TextButton" then v2:Destroy() end end for i,Morph in pairs(v3:GetChildren()) do local Button2 = Instance.new("TextButton") Button2.Size = UDim2.new(1,0,0,50) Button2.BackgroundTransparency = 1 Button2.Font = "SciFi" Button2.TextSize = 30 Button2.TextXAlignment = "Left" Button2.TextColor3 = Color3.fromRGB(255,255,255) Button2.Text = Morph.Name Button2.Parent = UniformFrame Button2.MouseButton1Click:connect (function() print(Button2.Text) RemoteEvent:FireServer(Morph, Button) end) end end) end
Here is the script:
-- This is just a part of the script the other things are unimportant. game.ReplicatedStorage.Youneedthis.OnServerEvent:Connect(function(Player, Morph, Button) coroutine.resume(coroutine.create(function() if Player.Character:FindFirstChild(Morph.Name) == nil then wait(0.1) local FindMorph = game.ReplicatedStorage.Morphs:FindFirstChild(Morph.Name) local Cloned = FindMorph:FindFirstChild(Button.Name):Clone() -- Error here Cloned.Parent = Player.Character for i, v in pairs(Cloned:GetChildren()) do coroutine.resume(coroutine.create(function() if v:IsA("BasePart") then if v.Name ~= "Middle" then local w = Instance.new("Weld") w.Part0 = Cloned["Middle"] w.Part1 = v w.C0 = w.Part0.CFrame:inverse() * CFrame.new(w.Part1.Position) w.C1 = w.Part1.CFrame:inverse() * CFrame.new(w.Part1.Position) w.Parent = w.Part0 else coroutine.resume(coroutine.create(function() wait(0.1) local w = Instance.new("Weld", Player.Character["Torso"]) w.Part0 = Player.Character["Torso"] w.Part1 = v w.C0 = CFrame.new(0, 0, 0) end)) end end end)) end
I found a fix myself by adding:
RemoteEvent:FireServer(Morph, Button, Button2)
It says no errors, but I found out the morph script isn't working.
game.ReplicatedStorage.Youneedthis.OnServerEvent:Connect(function(Player, Morph, Button, Button2) coroutine.resume(coroutine.create(function() if Player.Character:FindFirstChild(Morph.Name) == nil then wait(0.1) local FindMorph = game.ReplicatedStorage:FindFirstChild(Button.Name) local Cloned = FindMorph:FindFirstChild(Button2.Name) local Cloned2 = Cloned:GetChildren() Cloned.Parent = Player.Character for i, v in pairs(Cloned:GetChildren()) do coroutine.resume(coroutine.create(function() if v:IsA("BasePart") then if v.Name ~= "Middle" then local w = Instance.new("Weld") w.Part0 = Cloned["Middle"] w.Part1 = v w.C0 = w.Part0.CFrame:inverse() * CFrame.new(w.Part1.Position) w.C1 = w.Part1.CFrame:inverse() * CFrame.new(w.Part1.Position) w.Parent = w.Part0 else coroutine.resume(coroutine.create(function() wait(0.1) local w = Instance.new("Weld", Player.Character["Torso"]) w.Part0 = Player.Character["Torso"] w.Part1 = v w.C0 = CFrame.new(0, 0, 0) end)) end end end)) end for i, v in pairs(Cloned:GetChildren()) do coroutine.resume(coroutine.create(function() if v:IsA("BasePart") then v.Anchored = false v.CanCollide = false end end)) end if Player.Character:findFirstChild("Shirt") ~= nil then Player.Character["Shirt"]:remove() end if Cloned2:findFirstChild("Shirt") ~= nil then Cloned:FindFirstChild("Shirt"):Clone().Parent = Player.Character end if Player.Character:findFirstChild("Pants") ~= nil then Player.Character["Pants"]:remove() end if Cloned2:findFirstChild("Pants") ~= nil then Cloned:FindFirstChild("Pants"):Clone().Parent = Player.Character end for i, v in pairs(Player.Character:GetChildren()) do coroutine.resume(coroutine.create(function() if v:IsA("CharacterMesh") then v:remove() end if v:IsA("Accessory") then v:remove() end end)) end end end)) end)
I do not understand why this is not working.
Quick fix, you need to use uppercases.
-- I declared all the locals above. for i,v3 in pairs(MorphsDir:GetChildren()) do local Button = Instance.new("TextButton") Button.Size = UDim2.new(1,0,0,50) Button.BackgroundTransparency = 1 Button.Font = "SciFi" Button.TextSize = 30 Button.TextXAlignment = "Left" Button.TextColor3 = Color3.fromRGB(255,255,255) Button.Text = v3.Name --//Made it uppercase Button.Parent = LegionFrame Button.MouseButton1Click:Connect(function() for i,v2 in pairs(UniformFrame:GetChildren()) do if v2.ClassName == "TextButton" then v2:Destroy() end end for i,Morph in pairs(v3:GetChildren()) do local Button2 = Instance.new("TextButton") Button2.Size = UDim2.new(1,0,0,50) Button2.BackgroundTransparency = 1 Button2.Font = "SciFi" Button2.TextSize = 30 Button2.TextXAlignment = "Left" Button2.TextColor3 = Color3.fromRGB(255,255,255) Button2.Text = Morph.Name Button2.Parent = UniformFrame Button2.MouseButton1Click:connect (function() print(Button2.Text) RemoteEvent:FireServer(Morph, Button) end) end end) end
Another thing is:
local Cloned = FindMorph:FindFirstChild(Button.Name):Clone() --//You cannot clone a name lol