I've made a script that changes your t-shirt when you click a textbutton, it works fine in studio but doesn't work at all, saying that everything is a nill value. I've tried the script in both a localscript and a standard one with no prevail. Can someone help me?
This is the script:
local decal = script.Parent:findFirstChild("Decal")
local hit = game.Players.LocalPlayer
local humanoid = hit.Character:findFirstChild("Humanoid")
local torso = hit.Character:findFirstChild("Torso")
function GetFace()
if torso ~= nil and humanoid ~= nil then
local shirt = hit.Parent:findFirstChild("Shirt Graphic")
if shirt ~= nil then
shirt.Graphic = decal.Texture
else
local altshirt = torso:findFirstChild("roblox")
if altshirt ~= nil then
altshirt.Texture = decal.Texture
else
print("Torso found. Shirt not found. Assumed to be a robot.")
end
end
else
print("Not a valid person! T-Shirt cannot be changed!")
end
end
script.Parent.MouseButton1Click:connect(GetFace)

6 comments
Does it print anything?
Nope, just an error saying hit a nil value.
Can you give the exact errors?
You're trying to index LocalPlayer from the workspace.
Is this a SurfaceGui?
game.Players.LocalPlayer Is this in a local script or a normal script?