Tool is not cloning properly

I have made this script so if you are a certain rank, it gives you a certain tool from replicated storage. The problem is, it is not cloning properly. It was but when I came back the next day it isn’t working anymore. I was wondering if one of you guys could look at the script and try to fix it and find some bugs in it. Thanks.


local ReplicatedStorage = game:GetService("ReplicatedStorage")
local debounce = false
local Values = script.Parent.Values
local BusinessClassName = Values.BusinessClassName.Value
local BusinessClassTicket = Values.BusinessClassTicket
local BusinessRank = Values.BusinessRank.Value
local Class3 = Values.Class3.Value
local EconomyClassName = Values.EconomyClassName.Value
local EconomyClassTicket = Values.EconomyClassTicket
local EconomyRank = Values.EconomyRank.Value
local FirstClassName = Values.FirstClassName.Value
local FirstClassTicket = Values.FirstClassTicket
local FirstClassRank = Values.FirstClassRank.Value
local InvestorClassName = Values.InvestorClassName.Value
local InvestorClassTicket = Values.InvestorClassTicket
local InvestorRank = Values.InvestorRank.Value
local groupID = Values.groupID.Value
local Gui = script.Parent:WaitForChild("LoadingGUI")
local GuiClone = Gui:Clone()
GuiClone.Parent = game.ReplicatedStorage



local Brick = script.Parent.SCIParts.Touch

Brick.Touched:Connect(function(hit)
	if debounce then return end
    if hit.Parent:FindFirstChild("Humanoid") then
        local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
	    if Player then	
            local Gui = game.ReplicatedStorage:WaitForChild("LoadingGUI")
            local GuiClone = Gui:Clone()
		    GuiClone.Parent = Player:WaitForChild("PlayerGui")
		    debounce = true
			wait(5)
		if Player then	
			elseif Player:GetRankInGroup(groupID) == EconomyRank then
				local ECT = ReplicatedStorage:WaitForChild(EconomyClassTicket.Value):Clone()
				ECT.Parent = Player:WaitForChild("Backpack")
			elseif Player:GetRankInGroup(groupID) == BusinessRank  then
				local BCT = ReplicatedStorage:WaitForChild(BusinessClassTicket.Value):Clone()
				BCT.Parent = Player:WaitForChild("Backpack")
			elseif Class3 == false and Player:GetRankInGroup(groupID) == FirstClassRank then
				local FCT = ReplicatedStorage:WaitForChild(FirstClassTicket.Value):Clone()
				FCT.Parent = Player:WaitForChild("Backpack")				
			elseif Class3 == true and Player:GetRankInGroup(groupID) >= FirstClassRank then
				local FCT = ReplicatedStorage:WaitForChild(FirstClassTicket.Value):Clone()
				FCT.Parent = Player:WaitForChild("Backpack")
			elseif Class3 == true then return  
			elseif  Class3 == false and Player:GetRankInGroup(groupID) >= InvestorRank then
				local ICT = ReplicatedStorage:WaitForChild(InvestorClassTicket.Value):Clone()		
						ICT.Parent = Player:WaitForChild("Backpack")
			    
			
			
			

		
		    end 
		end
		
	end
end)


Ur cloning it into replicated storage not the played backpack…

Which part of the script???

The last line of the script.,…

Ohhhhhhhhh, my bad i didn’t see the rest of the script

Use get role in group instead of rank.

Try setting the parent of the cloned tool to player.Character rather than player.Backpack.

1 Like

Do you mind telling me the part?

Try this: ?

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local debounce = false
local Values = script.Parent.Values
local BusinessClassName = Values.BusinessClassName.Value
local BusinessClassTicket = Values.BusinessClassTicket
local BusinessRank = Values.BusinessRank.Value
local Class3 = Values.Class3.Value
local EconomyClassName = Values.EconomyClassName.Value
local EconomyClassTicket = Values.EconomyClassTicket
local EconomyRank = Values.EconomyRank.Value
local FirstClassName = Values.FirstClassName.Value
local FirstClassTicket = Values.FirstClassTicket
local FirstClassRank = Values.FirstClassRank.Value
local InvestorClassName = Values.InvestorClassName.Value
local InvestorClassTicket = Values.InvestorClassTicket
local InvestorRank = Values.InvestorRank.Value
local groupID = Values.groupID.Value
local Gui = script.Parent:WaitForChild("LoadingGUI")
local GuiClone = Gui:Clone()
GuiClone.Parent = game.ReplicatedStorage

local Brick = script.Parent.SCIParts.Touch

Brick.Touched:Connect(function(hit)
	if debounce then return end
    if hit.Parent:FindFirstChild("Humanoid") then
        local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
	    if Player then	
            local Gui = game.ReplicatedStorage:WaitForChild("LoadingGUI")
            local GuiClone = Gui:Clone()
		    GuiClone.Parent = Player:WaitForChild("PlayerGui")
		    debounce = true
			wait(5)
		end	
		if Player then	
			if Player:GetRankInGroup(groupID) == "" then -- Edit this part.
				-- And here too.
			elseif Player:GetRankInGroup(groupID) == EconomyRank then
				local ECT = ReplicatedStorage:WaitForChild(EconomyClassTicket.Value):Clone()
				ECT.Parent = Player:WaitForChild("Backpack")
			elseif Player:GetRankInGroup(groupID) == BusinessRank  then
				local BCT = ReplicatedStorage:WaitForChild(BusinessClassTicket.Value):Clone()
				BCT.Parent = Player:WaitForChild("Backpack")
			elseif Class3 == false and Player:GetRankInGroup(groupID) == FirstClassRank then
				local FCT = ReplicatedStorage:WaitForChild(FirstClassTicket.Value):Clone()
				FCT.Parent = Player:WaitForChild("Backpack")				
			elseif Class3 == true and Player:GetRankInGroup(groupID) >= FirstClassRank then
				local FCT = ReplicatedStorage:WaitForChild(FirstClassTicket.Value):Clone()
				FCT.Parent = Player:WaitForChild("Backpack")
			elseif Class3 == true then return  
			elseif  Class3 == false and Player:GetRankInGroup(groupID) >= InvestorRank then
				local ICT = ReplicatedStorage:WaitForChild(InvestorClassTicket.Value):Clone()		
				ICT.Parent = Player:WaitForChild("Backpack")
		    end 
		end
	end
end)

I noticed you forgot to put a end in one of the if statements. And also, was 2 if statements made on purpose, like they were meant to be separeted from eachother?