Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Does anyone know why... (STILL NOT ANSWERED)?

The Shirt And Pants is the only thing that doesnt work in game but it does in studio.

MultiFrame = script.Parent.Parent.Parent.MultiPurpose
script.Parent.MouseEnter:connect(function(info)
	MultiFrame.NameT.Text = "Kyle Argent"
	MultiFrame.AbilitiesT.Text = "Enhanced Senses, Speed, Strength"
	MultiFrame.AgeT.Text = "18"
	MultiFrame.ThingT.Text = "Werewolf"
	MultiFrame.GenderT.Text = "Male"
	local BC = script.Parent.Parent.Parent.Parent.Parent.Character:findFirstChild("Body Colors")
 local Shirt = script.Parent.Parent.Parent.Parent.Parent.Character:findFirstChild("Shirt")
	local Pants = script.Parent.Parent.Parent.Parent.Parent.Character:findFirstChild("Pants")
BC.HeadColor = BrickColor.new("Nougat")
 BC.TorsoColor = BrickColor.new("Nougat")
 BC.LeftLegColor  = BrickColor.new("Nougat")
 BC.RightLegColor = BrickColor.new("Nougat")
 BC.RightArmColor = BrickColor.new("Nougat")
 BC.LeftArmColor  = BrickColor.new("Nougat")	
 
script.Parent.Parent.Parent.Parent.Parent.Character.Head.face.Texture = "http://www.roblox.com/asset/?id=149116550"
Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=282722132"
Pants.PantsTemplate = "http://www.roblox.com/asset/?id=258284587"
 	local d = script.Parent.Parent.Parent.Parent.Parent.Character:GetChildren() 
	for i=1, #d do 
		if (d[i].className == "Hat") then 
			d[i]:remove() 
		end 
	end
local KAH = game:GetService("ReplicatedStorage").KAHair:Clone()
      KAH.Parent =  script.Parent.Parent.Parent.Parent.Parent.Character

	

end)

2 answers

There are one or two ways I would fix this. Instead of declaring the shirt, find out if it is even there:

local Shirt = script.Parent.Parent.Parent.Parent.Parent.Character:findFirstChild("Shirt")
local Pants = script.Parent.Parent.Parent.Parent.Parent.Character:findFirstChild("Pants")
if Shirt then
print("Shirt has been found!")
else
print("There is no shirt.")
end

if Pants then
print("Pants have been found!")
else 
print("Erm... this guy ain't wearing any pants...")
end

But, I would also go a step further than this, what if (for some reason) the shirt and pants that a player is wearing arn't called "Shirt" and "Pants"? Lets make a loop to find out:

for i,v in pairs (script.Parent.Parent.Parent.Parent.Parent:GetChildren())
if v:IsA("Shirt") then
Shirt=v
end
if v:IsA("Pants") then
Pants=v
end
end

If all else fails, hit f9 to open up the developer console in online mode, that way you can check for any errors directly.

4 comments

0

IsA?

0

It works in the studio but still not in game

0

:IsA() is a built in function used for finding out if a object is a Shirt or a Tool or any Instance. It will return true if the current child is a "Shirt".

0

The problem isnt showing up in Developer Console either

What kind of script is this (i.e. localscript, script, modulescript), and where is it in the game (i.e. the player, the workspace, etc.)? also is this script assigning it self to the studio player known as "Player1" or the like? as this is the cause of most "works in studio but not in game" problems.

This discussion is preserved as it was. New answers, comments, and votes are closed.