Uniform Giver Help

I am unable to get my uniform giver part to work anyone who is got rank ID 6+ should be given the uniform unless they own the uniform bypass gamepass.

local ChangerPart = script.Parent
local OutfitChanger = ChangerPart.Parent
local ShirtTemplate = OutfitChanger.Shirt.ShirtTemplate
local PantsTemplate = OutfitChanger.Pants.PantsTemplate

ChangerPart.Touched:Connect(function(TouchPart, plr)
    if plr:GetRankInGroup(11679839) < 6 then return end
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, GamePass) then return end
        if TouchPart and TouchPart.Parent and TouchPart.Parent:FindFirstChild("Humanoid") then
        print("Player Got Uniform")
        local Character = TouchPart.Parent
        Character.Shirt.ShirtTemplate = ShirtTemplate
        Character.Pants.PantsTemplate = PantsTemplate
    end
end)

WRONGNGNGNNGN

if plr:GetRankInGroup(11679839) then else return end

Wrong category #help-and-feedback:scripting-support is correcr

Im wanting it so the rank IDs below 6 don’t have the uniform so only staff can get it.

Moved category’s.
@commitblue

local ChangerPart = script.Parent
local OutfitChanger = ChangerPart.Parent
local ShirtTemplate = OutfitChanger.Shirt.ShirtTemplate
local PantsTemplate = OutfitChanger.Pants.PantsTemplate
local MPS = game:GetService("MarketplaceService")
local GamePassID = 0000000


ChangerPart.Touched:Connect(function(Object)
	if Object.Parent:FindFirstChild("Humanoid") then
		local plr = game.Players:GetPlayerFromCharacter(Object.Parent)
		if plr then
			if plr:GetRankInGroup(11679839) then return end
			--Using Pcalls() to avoid problems.

			local success, result = pcall(MPS:UserOwnsGamePassAsync(plr.UserId,GamePassID)) 
			if success then
				if  result then
					local Character = Object.Parent
					Character.Shirt.ShirtTemplate = ShirtTemplate
					Character.Pants.PantsTemplate = PantsTemplate
				end
			end
		end
	end
end)

A few notes :

1-When using .Touched, you usually don’t need more than 1 parameter. You can use 1 and use it to get the player and its character.

2-When working with Badges ,Gamepasses, Groups, etc… it’s better to work with pcalls.

Alright ty, however I want it so members with group ID 6+ can get the uniform. This makes it so all group members can not get the uniform.

if plr:GetRankInGroup(11679839) then return end

Alright, then do this :

local ChangerPart = script.Parent
local ShirtTemplate = "rbxassetid://1210857662"
local PantsTemplate = "rbxassetid://1210858279"
local MPS = game:GetService("MarketplaceService")
local GamePassID = 15447425


ChangerPart.Touched:Connect(function(Object)
	if Object.Parent:FindFirstChild("Humanoid") then
		local plr = game.Players:GetPlayerFromCharacter(Object.Parent)
		if plr then
			if plr:GetRankInGroup(9854805) > 6 then return end
			--Using Pcalls() to avoid problems.
			
			local success, result = pcall(function()
				if MPS:UserOwnsGamePassAsync(plr.UserId,GamePassID) then
					Object.Parent.Shirt.ShirtTemplate = ShirtTemplate
					Object.Parent.Pants.PantsTemplate = PantsTemplate
	            end
			end)
		end
	end
end)

Change the Shirt and Pants ID’s into what you want

Notice that if your rank is higher than 6, you won’t get the clothes, you can change the number and the sign

>= means more or equal to.
<= means less or equal to.
== means equal to.
~= means not equal to.

Now with this in mind, you can use this script with the following key above to change the script:

local ChangerPart = script.Parent
local OutfitChanger = ChangerPart.Parent
local ShirtTemplate = OutfitChanger.Shirt.ShirtTemplate
local PantsTemplate = OutfitChanger.Pants.PantsTemplate

ChangerPart.Touched:Connect(function(Hit)
    local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)

    if not Player then return end
    if not Player:GetRankInGroup(11679839) >= 6 then return end
    if not game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, GamePass) then return end

    print(Player.Name.." Got The Uniform")
    local Character = Player.Character
    Character.Shirt.ShirtTemplate = ShirtTemplate
    Character.Pants.PantsTemplate = PantsTemplate
end)

Hopefully, this helped you learn a thing or two! Make sure to mark me (or anyone) as the solution to assist the SEO! :grin:

Still doesn’t work?? (30 limit)

What does it print to you?

Could you show a clip?

Because for me it does.

local ChangerPart = script.Parent
local ShirtTemplate = "rbxassetid://1210857662"
local PantsTemplate = "rbxassetid://1210858279"
local MPS = game:GetService("MarketplaceService")
local GamePassID = 15447425


ChangerPart.Touched:Connect(function(Object)
	if Object.Parent:FindFirstChild("Humanoid") then
		local plr = game.Players:GetPlayerFromCharacter(Object.Parent)
		if plr then
			if plr:GetRankInGroup(9854805) >= 6 then return end
			--Using Pcalls() to avoid problems.
			
			local success, result = pcall(function()
				if MPS:UserOwnsGamePassAsync(plr.UserId,GamePassID) then
					Object.Parent.Shirt.ShirtTemplate = ShirtTemplate
					Object.Parent.Pants.PantsTemplate = PantsTemplate
	            end
			end)
		end
	end
end)
1 Like

It works for me EXplain why it doesn’t show me a clip you’re being uncooperative so DO IT

There are no errors but:

  1. It gives me the uniform even though i own the gamepass (yyes i changed the ID)
  2. users who are ranked 6+ and dont own the gamepass dont get the uniform when they should?

also check if the player’s character has a shirt and pants
I believe that some players do not wear this clothings and it would not add to the player’s character ingame

try

local Marketplace = game:GetService("MarketplaceService")

local ChangerPart = script.Parent
local OutfitChanger = ChangerPart.Parent
local OriginShirt = OutfitChanger.Shirt
local OriginPants = OutfitChanger.Pants


local GroupId = 000000
local GamePassId = 000000

ChangerPart.Touched:Connect(function(Object)
	local Player = game.Players:GetPlayerFromCharacter(Object.Parent)
	if not Player then return end

	local Result, Config = pcall(function() 
		if Player:GetRankInGroup(GroupId) < 6
			and not Marketplace:UserOwnsGamePassAsync(Player.UserId, GamePassId)
		then return false
		end

		return true
	end)

	if not Result then
		warn("Something Went Wrong")
	elseif Config then 
		local Character = Object.Parent

		local Shirt = Character:FindFirstChildWhichIsA("Shirt")
		local Pants = Character:FindFirstChildWhichIsA("Pants")

		if Shirt then
			Shirt.ShirtTemplate = OriginShirt.ShirtTemplate 
		else
			local NewShirt = OriginShirt:Clone()
			NewShirt.Parent = Character
		end
		if Pants then
			Pants.PantsTemplate = OriginPants.PantsTemplate
		else
			local NewPants = OriginPants:Clone()
			NewPants.Parent = Character
		end
	else
		print("Player Rank In Group Is Not 6+ Or Player Do Not Have The Gamepass")
	end

end)