Everything works fine in studio but when in game it wont work, please help, its suppose to change your clothes when you chat
-- Scripted By Architectix --
game.Players.PlayerAdded:connect(function(Player)
wait(1)
Player.Chatted:connect(function(chat)
wait(1)
local Char = game.Players.LocalPlayer.Character -- this is the line that keeps messing up --
-------------------------------------------------
if (chat == "GPDUni" or "GPDUniform") then
if Char ~= nil then
local Shirt = Char:WaitForChild("Shirt")
Shirt.ShirtTemplate = "rbxassetid://347880617"
local Pants = Char:WaitForChild("Pants")
Pants.PantsTemplate = "rbxassetid://337925943"
end
end
----------------------------------------------------
end)
end)

2 comments
it still won't work in game though and i tried starting a server and i didn't get any errors
The problem is that the player that spawns when you start a server don't have shirts or pants to begin with, so you can't just use :WaitForChild() (because it will yield forever). I edited the script to accommodate this.