Script in Serverscriptservice. Doesn’t fully work if the player is on team KID it doesn’t change his outfit or size, but if your on team ADULT it will change his clothing. no errors why won’t this work? How can I fix this?
game.Players.PlayerAdded:Connect(function(plr)
local function onCharacterAdded(character)
local function updateAppearance()
if plr.Team and character then
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
if plr.Team.Name == "KID" then
-- Change clothing (shirt and pants)
local shirt = character:FindFirstChildOfClass("Shirt")
if not shirt then
shirt = Instance.new("Shirt", character)
end
shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=7251537145" -- Replace with the asset ID of the shirt
local pants = character:FindFirstChildOfClass("Pants")
if not pants then
pants = Instance.new("Pants", character)
end
pants.PantsTemplate = "http://www.roblox.com/asset/?id=7194154562" -- Replace with the asset ID of the pants
-- Make the character smaller
humanoid.BodyHeightScale.Value = 0.5
humanoid.BodyWidthScale.Value = 0.5
humanoid.BodyDepthScale.Value = 0.5
humanoid.HeadScale.Value = 0.5
elseif plr.Team.Name == "ADULT" then
-- Change clothing (shirt and pants)
local shirt = character:FindFirstChildOfClass("Shirt")
if not shirt then
shirt = Instance.new("Shirt", character)
end
shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=9802863445" -- Replace with the asset ID of the shirt
local pants = character:FindFirstChildOfClass("Pants")
if not pants then
pants = Instance.new("Pants", character)
end
pants.PantsTemplate = "http://www.roblox.com/asset/?id=9803040200" -- Replace with the asset ID of the pants
-- Reset character size (or apply other modifications as needed)
humanoid.BodyHeightScale.Value = 1
humanoid.BodyWidthScale.Value = 1
humanoid.BodyDepthScale.Value = 1
humanoid.HeadScale.Value = 1
end
end
end
end
updateAppearance()
plr:GetPropertyChangedSignal("Team"):Connect(updateAppearance)
end
-- Connect the function to CharacterAdded to handle when the character spawns
plr.CharacterAdded:Connect(onCharacterAdded)
-- Initial check in case the player already has a character
if plr.Character then
onCharacterAdded(plr.Character)
end
end)