Uniform script help

I am making a ranked uniform script for my friends game, and I am having trouble with getting it to work properly. Its supposed to work by when you press a GUI button, it checks the role of the group you are in via a localscript, and will send that info to the server via a RemoteEvent. A script in ServerScriptService will then determine what rank you are, and give you a uniform with the correct rank.

Currently, when I press the button, it successfully sends the information sends the information to the server but instead of converting the rank name into the correct uniform ID, it just puts the rank name in where the template ID is supposed to go.

Here is the script in ServerScriptService (Named “uniformScript”):

game.ReplicatedStorage.changeUniform.OnServerEvent:Connect(function(plr, RankID, clothingType, clothingType2)
	local uniforms = {Sheriff = 6057413842, Undersheriff = 5947377389, AssistantSheriff = 5947376554, Major = 5947375838, Captain = 5947375110, Lieutenant = 5947373777, Sergeant = 5947373191, Corporal = 5947372240, DeputyFirstClass = 5947371235, SheriffDeputy = 5941694722}
	if not plr.Character:FindFirstChildOfClass("Shirt") then
		local Shirt = Instance.new("Shirt", plr.Character)
		Shirt.ShirtTemplate = "rbxassetid://"..RankID
	else
		local shirt = plr.Character:FindFirstChildOfClass("Shirt")
		shirt.ShirtTemplate = "rbxassetid://"..RankID
	end
end)

Local script in GUI button:

plr = game:GetService("Players").LocalPlayer
Event = game.ReplicatedStorage.changeUniform
clothingType = "Shirt"
clothingType2 = "Pants"
script.Parent.Activated:Connect(function()
	local RankID = plr:GetRoleInGroup(11020719)
	print(RankID)
	Event:FireServer(RankID, clothingType, clothingType2)
end)
1 Like

Change this part

For this

game.ReplicatedStorage.changeUniform.OnServerEvent:Connect(function(plr, RankID,     clothingType, clothingType2)
	local uniforms = {Sheriff = 6057413842, Undersheriff = 5947377389, AssistantSheriff = 5947376554, Major = 5947375838, Captain = 5947375110, Lieutenant = 5947373777, Sergeant = 5947373191, Corporal = 5947372240, DeputyFirstClass = 5947371235, SheriffDeputy = 5941694722}
	
	local Shirt = plr.Character:FindFirstChildOfClass("Shirt") or Instance.new("Shirt", plr.Character)
	Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="..RankID
end)

I’m not sure what you want to do

Still has the same problem
image

Oh, it only remains to look for it in the table

game.ReplicatedStorage.changeUniform.OnServerEvent:Connect(function(plr, RankID,     clothingType, clothingType2)
	local uniforms = {Sheriff = 6057413842, Undersheriff = 5947377389, AssistantSheriff = 5947376554, Major = 5947375838, Captain = 5947375110, Lieutenant = 5947373777, Sergeant = 5947373191, Corporal = 5947372240, DeputyFirstClass = 5947371235, SheriffDeputy = 5941694722}

	local Shirt = plr.Character:FindFirstChildOfClass("Shirt") or Instance.new("Shirt", plr.Character)
	Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=".. uniforms[RankID] or 0
end)

Just do

local sheriff = 
local undersheriff =

This would be easier.

It worked, other than the fact that the url part was rbxassetid:// instead of http://www.roblox.com/asset/?id= the ID was the shirt ID, not the template ID. Thank you very much!

I had it working before, however it was like 100 lines of code because i used a bunch of elseif’s, and wanted to use this method in order to make it more efficient