So I made a script that uses clothes when you spawn and it works PERFECTLY when i press play on Roblox studio it works fine but when I play in a real game it does not work! (filtering not enables)
is is what i have:
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
game.Players.LocalPlayer.PlayerGui.ScreenGui.GOB.Girl.MouseButton1Click:connect(function()
game.Players.LocalPlayer.PlayerGui.ScreenGui.BegineChoose.Prisoners.MouseButton1Click:connect(function()
print("hello")
Delay(1, function()
local stuff = char:GetChildren()
for i = 1,#stuff do
if stuff[i].ClassName=="Hat" or stuff[i].ClassName == "ShirtGraphic" or stuff[i].ClassName=="Pants" or stuff[i].ClassName == "Shirt" or stuff[i].ClassName == "BodyColors" or stuff[i].ClassName == "CharacterMesh" --[[ do you want charactermesh to be removed? Else put it out!--]] then
stuff[i]:Remove()
end
end
local stuff1 = char.Torso:GetChildren()
for i = 1,#stuff1 do
if stuff1[i].ClassName=="Decal" then
stuff1[i]:Remove()
end
end
local hat1 = game.ServerStorage.UniformG.Hats1:GetChildren()
if #hat1 >0 then
local i = math.random (1,#hat1)
hat1[i]:Clone().Parent=char
hat1[i].Handle.Position = char.Head.Position
end
local hat2 = game.ServerStorage.UniformG.Hats2:GetChildren()
if #hat2 >0 then
local i = math.random (1,#hat2)
hat2[i]:Clone().Parent=char
hat2[i].Handle.Position = char.Head.Position
end
local hat3 = game.ServerStorage.UniformG.Hats3:GetChildren()
if #hat3 >0 then
local i = math.random (1,#hat3)
hat3[i]:Clone().Parent=char
hat3[i].Handle.Position = char.Head.Position
end
local shirts = game.ServerStorage.UniformG.Shirts:GetChildren()
if #shirts >0 then
local i = math.random(1,#shirts)
shirts[i]:Clone().Parent=char
end
local Pants = game.ServerStorage.UniformG.Pants:GetChildren()
if #Pants >0 then
local i = math.random (1,#Pants)
Pants[i]:Clone().Parent=char
end
local bodycolor = game.ServerStorage.UniformG.BodyColors:GetChildren()
if #bodycolor >0 then
local i = math.random(1,#bodycolor)
char:FindFirstChild("Head").BrickColor = bodycolor[i].Value
char:FindFirstChild("Left Arm").BrickColor = bodycolor[i].Value
char:FindFirstChild("Left Leg").BrickColor = bodycolor[i].Value
char:FindFirstChild("Right Arm").BrickColor = bodycolor[i].Value
char:FindFirstChild("Right Leg").BrickColor = bodycolor[i].Value
char:FindFirstChild("Torso").BrickColor = bodycolor[i].Value
end
local faces = game.ServerStorage.UniformG.Faces:GetChildren()
if #faces > 0 then
local stuff2 = char.Head:GetChildren()
for i =1,#stuff2 do
if stuff2[i].ClassName=="Decal" then
stuff2[i]:Remove()
end
end
local i = math.random(1,#faces)
faces[i]:Clone().Parent=char.Head
end
local packages = game.ServerStorage.UniformG.Package:GetChildren()
if #packages > 0 then
local i = math.random (1,#packages)
local stuff3 = packages[i]:GetChildren()
for i = 1, #stuff3 do
stuff3[i]:Clone().Parent=char
end
end
end)
end)
end)
end)
end)

3 comments
You can't access PlayerGui via ServerScript m8
Is this script server or local?
Hmm it cant be local script and has to be in starter player scripts