I’m trying to make a stopwork feature for my game and is there a way to reset the players 2d clothing to their original clothing once I’ve ran the !stopwork command because I have a uniform system that puts a uniform on the player character.
Please note that I can’t respawn the player’s character or load the character as I have other scripts that make the character respawn at their team spawn once they respawn or load their character.
My script:
local GROUP_ID = 5062496
local REQUIRED_RANK = 2
local SPAWN_LOCATION_NAME = "CustomerSpawn"
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
if player:GetRankInGroup(GROUP_ID) >= REQUIRED_RANK and message == "!stopwork" then
local spawnLocation = game.Workspace:FindFirstChild(SPAWN_LOCATION_NAME)
if spawnLocation and spawnLocation:IsA("BasePart") then
local character = player.Character
if character then
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if humanoidRootPart then
humanoidRootPart.CFrame = CFrame.new(spawnLocation.Position)
local rankGui = character.Head:FindFirstChild("RankifyOverhead")
if rankGui and rankGui:IsA("BillboardGui") then
local rankTag = rankGui:FindFirstChild("Secondary")
if rankTag and rankTag:IsA("TextLabel") then
rankTag.Text = "Off-Duty"
end
end
end
end
end
end
end)
end)
```
You can use attributes to store the player’s original clothing, and then retrieve it here.
Code:
local GROUP_ID = 5062496
local REQUIRED_RANK = 2
local SPAWN_LOCATION_NAME = "CustomerSpawn"
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
if player:GetRankInGroup(GROUP_ID) >= REQUIRED_RANK and message == "!stopwork" then
local spawnLocation = workspace:FindFirstChild(SPAWN_LOCATION_NAME)
if spawnLocation and spawnLocation:IsA("BasePart") then
local character = player.Character
local humanoidRootPart = character and character:FindFirstChild("HumanoidRootPart")
if humanoidRootPart then
humanoidRootPart.CFrame = CFrame.new(spawnLocation.Position)
local rankGui = character.Head:FindFirstChild("RankifyOverhead")
local rankTag = rankGui and rankGui:FindFirstChild("Secondary")
if rankTag and rankTag:IsA("TextLabel") then
rankTag.Text = "Off-Duty"
end
-- Reset clothing
character.Shirt.ShirtTemplate = player:GetAttribute("ShirtId")
character.Pants.PantsTemplate = player:GetAttribute("PantsId")
end
end
end
end)
end)
Other code:
-- Set player's clothes to work clothes
player:SetAttribute("ShirtId", player.Character.Shirt.ShirtTemplate)
player:SetAttribute("PantsId", player.Character.Pants.PantsTemplate)
player.Character.Shirt.ShirtTemplate = whatever
player.Character.Pants.PantsTemplate = whatever