✓ Accepted answer
You're changing the StarterCharacter. This gets put into a players character once they join.
To change their shirt and pants. You'd need to find the players character and change it from their Character Model.
Hopefully this code will clear some stuff up.
P.S - Put this into a default script. LocalScripts do not execute in Workspace.
Gate = script.Parent
Gate.Touched:Connect(function(hit)
if hit and hit.Parent:FindFirstChild("Humanoid") then
local Shirt = hit.Parent:FindFirstChild("Shirt")
if not Shirt then
local CreateShirt = Instance.new("Shirt")
CreateShirt.Parent = hit.Parent
CreateShirt.Name = "Shirt"
CreateShirt.ShirtTemplate = "http://www.roblox.com/asset/?id=584017370"
else
Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=584017370"
end
local Pants = hit.Parent:FindFirstChild("Pants")
if not Pants then
local CreatePants = Instance.new("Pants")
CreatePants.Parent = hit.Parent
CreatePants.Name = "Pants"
CreatePants.PantsTemplate = "http://www.roblox.com/asset/?id=584017819"
else
Pants.PantsTemplate = "http://www.roblox.com/asset/?id=584017819"
end
end
end)
Alternative (Without Debugging Code [If you want concise, fast code]):
Gate = script.Parent
Gate.Touched:Connect(function(hit)
if hit and hit.Parent:FindFirstChild("Humanoid") then
local Shirt = hit.Parent:FindFirstChild("Shirt")
Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=584017370"
local Pants = hit.Parent:FindFirstChild("Pants")
Pants.PantsTemplate = "http://www.roblox.com/asset/?id=584017819"
end
end)