Hey DevForum, I have been sitting on this broken script for some time now. What this is supposed to do is make the player’s head, legs, and arms the default mesh upon joining. However, the torso can either be the default one or the woman torso if they join already wearing it. I’m very new to scripting and this has been on my list of “stuff I’ll get back to at some point” for a while now. Any help would be appreciated!
local Players = game.Players
function PlayerJoined(Player)
local function RemoveMeshes(Character)
local Humanoid = Character:WaitForChild("Humanoid")
wait()
local CurrentDescription = Humanoid:GetAppliedDescription()
if not CurrentDescription.Torso == 48474356 or not CurrentDescription.Torso == 0 then
CurrentDescription.Torso = 0
end
CurrentDescription.Head = "0"
CurrentDescription.LeftArm = "0"
CurrentDescription.RightArm = "0"
CurrentDescription.LeftLeg = "0"
CurrentDescription.RightLeg = "0"
Humanoid:ApplyDescription(CurrentDescription)
end
Player.CharacterAppearanceLoaded:Connect(RemoveMeshes)
end
Players.PlayerAdded:Connect(PlayerJoined)
local Players = game.Players
function PlayerJoined(Player)
local function RemoveMeshes(Character)
local Humanoid = Character:WaitForChild("Humanoid")
local CurrentDescription = Humanoid:GetAppliedDescription()
if CurrentDescription.Torso ~= 48474356 and CurrentDescription.Torso ~= 0 then
CurrentDescription.Torso = 0
end
CurrentDescription.Head = 0 -- these should all be numbers
CurrentDescription.LeftArm = 0
CurrentDescription.RightArm = 0
CurrentDescription.LeftLeg = 0
CurrentDescription.RightLeg = 0
Humanoid:ApplyDescription(CurrentDescription)
end
if Player.Character then RemoveMeshes(Player.Character) end -- check if the player's character already loaded first
Player.CharacterAppearanceLoaded:Connect(RemoveMeshes)
end
Players.PlayerAdded:Connect(PlayerJoined)
Hello, I think I figured out the issue in your script which is that The condition not CurrentDescription.Torso == 48474356 or not CurrentDescription.Torso == 0 is incorrect. The correct condition should be
if CurrentDescription.Torso ~= 48474356 and CurrentDescription.Torso ~= 0 then
CurrentDescription.Torso = 0
end
You guys were actually both right about changing how I defined the ids for CurrentDescription.Torso, so heres the fixed and annotated script that will work when put into Workspace.
-- Get the Players service from the game
local Players = game:GetService("Players")
-- Function that runs when a player joins the game
local function PlayerJoined(player)
-- Function to remove meshes and set the default mesh for the player
local function RemoveMeshes(character)
-- Get the Humanoid object from the character
local humanoid = character:WaitForChild("Humanoid")
wait()
-- Get the current appearance description of the humanoid
local CurrentDescription = humanoid:GetAppliedDescription()
-- Check if the player's torso is not equal to 0 or 48474356, then set it to 0
if CurrentDescription.Torso ~= 0 and CurrentDescription.Torso ~= 48474356 then
CurrentDescription.Torso = 0
end
-- Set the head, arms, and legs to the default mesh (id 0)
CurrentDescription.Head = 0
CurrentDescription.LeftArm = 0
CurrentDescription.RightArm = 0
CurrentDescription.LeftLeg = 0
CurrentDescription.RightLeg = 0
-- Apply the modified appearance description to the humanoid
humanoid:ApplyDescription(CurrentDescription)
end
-- Connect the RemoveMeshes function to the CharacterAppearanceLoaded event of the player
player.CharacterAppearanceLoaded:Connect(RemoveMeshes)
end
-- Connect the PlayerJoined function to the PlayerAdded event of the Players service
Players.PlayerAdded:Connect(PlayerJoined)