Staff only shirt

Script in ServerScriptService.
Change 5586414654 to your shirtID.
Change 0000000000 to your groupID.

local character, shirt = nil, nil
game.Players.PlayerAdded:Connect(function(player)
	if player:IsInGroup(0000000000) then
		character = player.CharacterAdded:Wait()
		task.wait(2) shirt = character:FindFirstChild("Shirt")
		if shirt then shirt.ShirtTemplate = "rbxassetid://5586414654"
		else local newShirt = Instance.new("Shirt") newShirt.Name = "Shirt"
			newShirt.ShirtTemplate = "rbxassetid://5586414654"
			newShirt.Parent = character
		end
	end
end)

task.wait(2) could probably be a 1, but it is needed.

Ok, if the staff is the only ones in the group why are we checking their rank?? Just check if they are in the group and front there give them the shirt.

BTW this is why it’s probably not working

All these scripts probably work, you just cant copy and paste the ID from the catalog, it needs to be the Asset ID, you can get this by applying the “catalog ID” to a decal or something similar, and copying the revised ID.

Thank you for pointing this out, I will try it when I get home later

This is a working shirt ID, Ive gone over that code for a few hours lastnight and it works perfectly.
I’m starting to think it was never even tested …

I’M BACK BABY! I’ve noticed this in your code:

-- Check if the shirt is there
			if shirt then
				shirt.ShirtTemplate = "rbxassetid://13523043925" .. staffShirtID -- Replace the shirt
			else
				-- If shirt doesn't exist, create a new one
				local newShirt = Instance.new("Shirt")
				newShirt.ShirtTemplate = "rbxassetid://13523046235" .. staffShirtID
				newShirt.Parent = character
			end

Specifically when it changes the shirt template. You are writing an ID and then the shirtID. To fix it, replace those lines with:

newShirt.ShirtTemplate = "rbxassetid://" .. staffShirtID

Or just try removing the "“rbxassetid://” … " all together.

I finally hit the error you stated with the no shirt just skin showing …
It has to be a string: ShirtTemplate = “rbxassetid://” … tostring(staffShirtID)
Or like this: ShirtTemplate = “rbxassetid://13523043925”

In the version I posted, I’m just changing the string itself.

Edit: in posting this the “rbxassetid://” … tostring(staffShirtID) looks like it has 3 dots on this post, but it is only 2 dots.

1 Like

Oh, yeah. So both of our points have to be applied. This is the correct script then?

-- Replace with the desired shirt ID and your group ID
local staffShirtID = 13523043925 
local groupID = 17256639 -- Your group ID goes here
local staffRankNumber = 1 -- Staff rank number goes here

local PlayerService = game:GetService("Players")

PlayerService.PlayerAdded:Connect(function(plr)
	-- Check player's rank in the group
	if plr:IsInGroup(groupID) and plr:GetRankInGroup(groupID) >= staffRankNumber then
		plr.CharacterAppearanceLoaded:Connect(function(character)
			local shirt = character:FindFirstChild("Shirt")
			-- Check if the shirt is there
			if shirt then
				shirt.ShirtTemplate = "rbxassetid://"..tostring(staffShirtID) -- Replace the shirt
			else
				-- If shirt doesn't exist, create a new one
				local newShirt = Instance.new("Shirt")
				newShirt.ShirtTemplate = "rbxassetid://"..tostring(staffShirtID)
				newShirt.Parent = character
			end
		end)
	end
end)

And if only the staff are in the group, remove the rank check:

-- Replace with the desired shirt ID and your group ID
local staffShirtID = 13523043925 
local groupID = 17256639 -- Your group ID goes here

local PlayerService = game:GetService("Players")

PlayerService.PlayerAdded:Connect(function(plr)
	-- Check player's rank in the group
	if plr:IsInGroup(groupID) then
		plr.CharacterAppearanceLoaded:Connect(function(character)
			local shirt = character:FindFirstChild("Shirt")
			-- Check if the shirt is there
			if shirt then
				shirt.ShirtTemplate = "rbxassetid://"..tostring(staffShirtID) -- Replace the shirt
			else
				-- If shirt doesn't exist, create a new one
				local newShirt = Instance.new("Shirt")
				newShirt.ShirtTemplate = "rbxassetid://"..tostring(staffShirtID)
				newShirt.Parent = character
			end
		end)
	end
end)

Or follow what my post said, and copy it as it was wrote and tested working.
Looks like you got it now. Keep in mind some object inputs need to be fully strings.

1 Like

Please do NOT ask for us to write a script for you. The Scripting Support category is designed for solving issues in your existing code.

Now you might say that some people already wrote a script for you, probably because it is easy to do for them. I believe they do not know the current rule in this category. So this shall serve as a reminder.

If you want someone to write a script, I suggest making it a commission.

2 Likes

I do know the rule, and was going to say it but forgot about it.