Here's the code :
Chars={ Chris={ ShirtId="282970025", PantsId="396974362", } } Character.OnServerEvent:connect(function(p,char) if p.Character:FindFirstChild("Shirt") and p.Character:FindFirstChild("Pants") then if char=="Chris" then p.Character.Shirt.ShirtTemplate="http://www.roblox.com/asset/?id="..Chars.Chris.ShirtId p.Character.Pants.PantsTemplate="http://www.roblox.com/asset/?id="..Chars.Chris.PantsId end
Whenever I try to fire it give no errors, but doesn't change the Pants or Shirt?
Any ideas why?
For instances where you get unexpected results with no error messages, it often means some condition for a certain code block wasn't met. This is a good sign, because it means your program has a way of handling a situation where something is out of place. Unfortunately, it can get a little bit frustrating to debug sometimes. But, let's not forget about one of the greatest debugging tools out there: the print
function.
Locate the region in your script that's causing the problem, and try placing a print
function after (and optionally, before) each conditional statement. The print message should be somewhat descriptive about the condition.
-- You don't always have to print something before the condition statement, but it can help in some cases print("Checking if table has pie...") if randomTable.piethen then -- Check 'randomTable' for index 'pie' print("Table indeed has pie") -- let us know the table has pie end
You should keep doing this for each conditional statement relevant to your problem, and analyze the output window very carefully to see the runtime progression of your code. In your case, it probably has something to do with char
either not being a string, or just not containing the same characters as "Chris", but this would just be an educated guess. You should gather this data first, and if you still haven't found the issue, report back with the information you gathered.