Hello
I tried to make a script that checks if the player has certain shirts/pants from a table and if they don’t it replaces it.
It seems like checking the tables must be the issue but I’m not sure how to fix it.
Currently it gives me the replaced outfit.
Here is the script
Shirts = {
"rbxassetid://9041476683",
"rbxassetid://9010875944",
"rbxassetid://9010870140",
"rbxassetid://10197365215",
"rbxassetid://9776861651",
"rbxassetid://9513082336",
"rbxassetid://10207652784",
"rbxassetid://9710458504"
} -- Shirt IDs
Pants = {
"rbxassetid://9010873129",
"rbxassetid://10197383329",
"rbxassetid://9776863373",
"rbxassetid://9513084493",
"rbxassetid://10207658360",
"rbxassetid://9710460441"
} -- Pants IDs
--[Uniform Whitelister]
game.Players.PlayerAdded:Connect(function(plar)
plar.CharacterAppearanceLoaded:Connect(function(char)
wait()
if plar.Team == team["Templars"] then
if char.Shirt.ShirtTemplate == Shirts[char.Shirt.ShirtTemplate] and char.Pants.PantsTemplate == Pants[char.Pants.PantsTemplate] then
print("Correct Uniform")
else
print("Incorrect Uniform")
char.Shirt.ShirtTemplate = "rbxassetid://125195175" -- Default Shirt
char.Pants.PantsTemplate = "rbxassetid://125195171" -- Default Pants
end
end
end)
end)
Tried this and nothing changed
Im trying to make it so if you are wearing a shirt and pants that are in the table then you can wear them otherwise it replaces them
This is what he means: Try and put one of the IDs in a shirt in Roblox Studio, it should change.
That should bring you to the template, you will need to use that link to change their shirt not the ID for the actual shirt itself. It should look identical to the shirts in your shirt table just different IDs for each
It should look like: “rbxassetid://123”, 123 being the ID
(Also dont mind what I said in the edits, I seen it in another post and didnt test it out, it doesnt work)
local Game = game
local Players = Game:GetService("Players")
local ShirtIds = {0, 1, 2, 3} --Enter whitelisted shirt IDs here.
local PantsIds = {0, 1, 2, 3} --Enter whitelisted pants IDs here.
local DefaultShirtId = 0 --ID of default shirt.
local DefaultPantsId = 0 --ID of default pants.
local function OnPlayerAdded(Player)
local function OnCharacterAdded(Character)
if not Player:HasAppearanceLoaded() then Player.CharacterAppearanceLoaded:Wait() end
local Shirt = Character:FindFirstChildOfClass("Shirt")
if Shirt then
local ShirtId = string.match(Shirt.ShirtTemplate, "%d+$")
ShirtId = tonumber(ShirtId)
if not table.find(ShirtIds, ShirtId) then Shirt.ShirtTemplate = "rbxassetid://"..DefaultShirtId end
else
Shirt = Instance.new("Shirt")
Shirt.ShirtTemplate = "rbxassetid://"..DefaultShirtId
Shirt.Parent = Character
end
local Pants = Character:FindFirstChildOfClass("Pants")
if Pants then
local PantsId = string.match(Pants.PantsTemplate, "%d+$")
PantsId = tonumber(PantsId)
if not table.find(PantsIds, PantsId) then Pants.PantsTemplate = "rbxassetid://"..DefaultPantsId end
else
Pants = Instance.new("Pants")
Pants.PantsTemplate = "rbxassetid://"..DefaultPantsId
Pants.Parent = Character
end
end
Player.CharacterAdded:Connect(OnCharacterAdded)
end
Players.PlayerAdded:Connect(OnPlayerAdded)