Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Error when using ":GetRankInGroup ()" on my uniform dupe code?

I basically setup something to dupe uniforms from ServerStorage for members on GUI click. However, once I added in the :GetRankInGroup portion it ceased working, however worked perfectly fine before? Getting an Error (134,39) expected "end to close function"

local player = game:GetService("Players").LocalPlayer
local character = player.Character
local Uniform = game.ServerStorage.Armor["TRC"].Standard["Standard - Cadet"].Clothing

function Click()
	if player:GetRankInGroup(1236263) >= 1 and player:GetRankInGroup(1236263)<= 255 then
	local hU = character:findFirstChild("Humanoid")
	if hU~=nil then
		local s = character:findFirstChild("Shirt")
		if s~=nil and y~=nil then
			character.Shirt:remove()
			Uniform.Shirt:clone().Parent = character
		elseif s~=nil then
			character.Shirt:remove()
			Uniform.Shirt:clone().Parent = character
		elseif y~=nil then
			character.Shirt:clone().Parent = character
		elseif s==nil and y==nil then
			character.Shirt:clone().Parent = character
		end
	end
end

User.MouseButton1Click:connect(Click)

Above is all the code. I didn't forget anything major did I? I mean I am fairly certain I wrote that right and it has an end function. So I don't understand as to why I am getting a script error.

1 comment

1

This is why it is important to tab your code correctly.

1 answer

✓ Accepted answer

You were missing end to finish your if statement on line 6. My guess is that you put in the if statement and forgot to end it at the bottom as well.

local player = game:GetService("Players").LocalPlayer
local character = player.Character
local Uniform = game.ServerStorage.Armor["TRC"].Standard["Standard - Cadet"].Clothing

function Click()
	if player:GetRankInGroup(1236263) >= 1 and player:GetRankInGroup(1236263)<= 255 then
		local hU = character:findFirstChild("Humanoid")
		if hU~=nil then
			local s = character:findFirstChild("Shirt")
			if s~=nil and y~=nil then
				character.Shirt:remove()
				Uniform.Shirt:clone().Parent = character
			elseif s~=nil then
				character.Shirt:remove()
				Uniform.Shirt:clone().Parent = character
			elseif y~=nil then
				character.Shirt:clone().Parent = character
			elseif s==nil and y==nil then					character.Shirt:clone().Parent = character
			end
		end
	end
end

User.MouseButton1Click:connect(Click)

You did a good job tabbing, but if you had fixed everything that should have been tabbed after the first if statement, you would have seen the missing end.

1 comment

0

I didn't realize I missed that. I appreciate the help, I was sure I had done it right, thanks.

This discussion is preserved as it was. New answers, comments, and votes are closed.