HELP, HELP, HELP. Im completely clueless on this matter and I need immediate assistance. Portions of my script wont run for whatever reason. After completing parts of it, the script will randomly stop halfway through and not read through the rest of it. Ive tried using other functions to cause this script to run fully, but its all for naught. Heres my code:
wait(2)
game.ReplicatedStorage.LoadPlayer.OnServerEvent:Connect(function(player)
local character = player.Character
task.wait(3)
local Data
Data = player:FindFirstChild("Data")
if not Data then
warn("No DATA for "..player.Name)
task.wait(2)
end
local Data1 = Data:WaitForChild("Character")
local PlayerInfo = _G.GetPlayerAppearanceInfo(player,Data1)
-- functions
local haModule = require(script.HairRarity)
local function HairRarity()
local number = math.random(1,50)
local found = false
local chosen = nil
while found == false do
task.wait()
for i,v in pairs(haModule) do
local num2 = math.random(1,v)
if num2 == number then
found = true
chosen = i
end
end
end
return chosen
end
local function SkinRarity(module)
local number = math.random(1,50)
local found = false
local chosen = nil
while found == false do
task.wait()
for i,v in pairs(module)do
local num2 = math.random(1,v)
if num2 == number then
found = true
chosen = i
end
end
end
return chosen
end
local c = Data:FindFirstChild("Customized")
local g = Data1:WaitForChild("Gender")
local Data2 = Data:WaitForChild("Vitality")
Data2.Chakra.Changed:Connect(function()
local min = 0
local max = Data2.MaxChakra.Value
Data2.Chakra.Value = math.clamp(Data2.Chakra.Value, min, max)
end)
Data2.Stamina.Changed:Connect(function()
local min = 0
local max = Data1.MaxStamina.Value
Data2.Stamina.Value = math.clamp(Data2.Stamina.Value, min, max)
end)
local function chooseGender()
if g then
if g.Value == "None" or g.Value == nil then
local ui = player.PlayerGui
local Gender = ui:WaitForChild("Gender")
Gender.Enabled = true
Gender.Handler.Disabled = false
local GenderValue = Data1:WaitForChild("Gender")
Gender.Frame.MaleB.MouseButton1Click:Connect(function()
g.Value = "Male"
end)
Gender.Frame.FemaleB.MouseButton1Click:Connect(function()
g.Value = "Female"
end)
end
end
end
if g.Value == "None" then
chooseGender()
end
local availableeyes = {"One", "Two"}
local eyetype = availableeyes[math.random(1, #availableeyes)]
Data1:WaitForChild("FaceType").Value = eyetype
local GenderValue = Data1:WaitForChild("Gender")
if Data1["HairColor"] then
if Data1["HairColor"].Value == "" or nil then
local chosenSpekn = HairRarity()
print(chosenSpekn)
Data1["HairColor"].Value = chosenSpekn
end
end
local newObject
for name, object in pairs(PlayerInfo) do
if name == "Hair" or name == "Accessories" then
for _,accessory in pairs(object) do
newObject = accessory:Clone()
local specialMesh = newObject.Handle:FindFirstChildWhichIsA("SpecialMesh")
newObject.Handle.BrickColor = BrickColor.new(Data1.HairColor.Value)
if specialMesh then
specialMesh.TextureId = "rbxassetid://652531618"
specialMesh.VertexColor = Vector3.new(newObject.Handle.Color.r,newObject.Handle.Color.g,newObject.Handle.Color.b)
end
newObject:Clone().Parent = character
end
end
end
local faceFolder = game.ServerStorage.faces
if GenderValue.Value == "Male" then
if Data1:WaitForChild("FaceType").Value == "One" then
local f1 = faceFolder.m:WaitForChild("1")
local brow = f1.eyebrows:clone()
local eye = f1.eye:clone()
local pup = f1.pupil:clone()
local nose = f1.nose:clone()
local eyecolor = Color3.new(math.random(),math.random(),math.random())
Data1.EyeColorR.Value = eyecolor.R
Data1.EyeColorG.Value = eyecolor.G
Data1.EyeColorB.Value = eyecolor.B
pup.Color3 = Color3.new(Data1.EyeColorR.Value, Data1.EyeColorG.Value, Data1.EyeColorB.Value)
brow.Color3 = newObject.Handle.Color
eye.Parent = character:WaitForChild("FakeHead")
pup.Parent = character:WaitForChild("FakeHead")
nose.Parent = character:WaitForChild("FakeHead")
brow.Parent = character:WaitForChild("FakeHead")
else
local f1 = faceFolder.m:WaitForChild("2")
local brow = f1.eyebrows:clone()
local eye = f1.eye:clone()
local pup = f1.pupil:clone()
local nose = f1.nose:clone()
local eyecolor = Color3.new(math.random(),math.random(),math.random())
Data1.EyeColorR.Value = eyecolor.R
Data1.EyeColorG.Value = eyecolor.G
Data1.EyeColorB.Value = eyecolor.B
pup.Color3 = Color3.new(Data1.EyeColorR.Value, Data1.EyeColorG.Value, Data1.EyeColorB.Value)
brow.Color3 = newObject.Handle.Color
eye.Parent = character:WaitForChild("FakeHead")
pup.Parent = character:WaitForChild("FakeHead")
nose.Parent = character:WaitForChild("FakeHead")
brow.Parent = character:WaitForChild("FakeHead")
end
elseif GenderValue.Value == "Female" then
if Data1:WaitForChild("FaceType").Value == "One" then
local f1 = faceFolder.f:WaitForChild("1")
local brow = f1.eyebrows:clone()
local eye = f1.eye:clone()
local pup = f1.pupil:clone()
local nose = f1.nose:clone()
local eyecolor = Color3.new(math.random(),math.random(),math.random())
Data1.EyeColorR.Value = eyecolor.R
Data1.EyeColorG.Value = eyecolor.G
Data1.EyeColorB.Value = eyecolor.B
pup.Color3 = Color3.new(Data1.EyeColorR.Value, Data1.EyeColorG.Value, Data1.EyeColorB.Value)
brow.Color3 = newObject.Handle.Color
eye.Parent = character:WaitForChild("FakeHead")
pup.Parent = character:WaitForChild("FakeHead")
nose.Parent = character:WaitForChild("FakeHead")
brow.Parent = character:WaitForChild("FakeHead")
else
local f1 = faceFolder.f:WaitForChild("2")
local brow = f1.eyebrows:clone()
local eye = f1.eye:clone()
local pup = f1.pupil:clone()
local nose = f1.nose:clone()
local eyecolor = Color3.new(math.random(),math.random(),math.random())
Data1.EyeColorR.Value = eyecolor.R
Data1.EyeColorG.Value = eyecolor.G
Data1.EyeColorB.Value = eyecolor.B
pup.Color3 = Color3.new(Data1.EyeColorR.Value, Data1.EyeColorG.Value, Data1.EyeColorB.Value)
brow.Color3 = newObject.Handle.Color
eye.Parent = character:WaitForChild("FakeHead")
pup.Parent = character:WaitForChild("FakeHead")
nose.Parent = character:WaitForChild("FakeHead")
brow.Parent = character:WaitForChild("FakeHead")
end
end
if Data1["SkinColor"] then
if Data1["SkinColor"].Value == "" or nil then
local moduletofind = script:FindFirstChild("SkinRarity")
if moduletofind then
local skmodule = require(moduletofind)
local chosenSk = SkinRarity(skmodule)
Data1["SkinColor"].Value = chosenSk
for i, v in pairs(character:GetChildren())do
if v:IsA("BasePart") then
v.BrickColor = BrickColor.new(Data1["SkinColor"].Value)
end
end
end
elseif Data1["SkinColor"].Value ~= "" then
for i, v in pairs(character:GetChildren())do
if v:IsA("BasePart") then
v.BrickColor = BrickColor.new(Data1["SkinColor"].Value)
end
end
end
end
end)