0

# How do I clone my tool to a backpack?

I can clone my tool to the backpack but when I reset it will be gone someone said use a CharacterAdded but I have no idea how I should change my script to after I use CharacterAdded heres the script.

--Script made by WINDOWS10XPRO

--[[
Title: KeyCardManagerScript
Goal: Gives keycard to specific rank in a group when they join the server
Description: This script is made by WINDOWS10XPRO. It's an open source. You can copy it if you want to.
]]--

--Variables:

local GroupID = 7495829 -- Your GroupID here
local ReplicatedStorage = game:GetService("ReplicatedStorage") -- ReplicatedStorage
local BlueKeyCard = ReplicatedStorage.BlueKeyCard -- Your Item
local YellowKeyCard = ReplicatedStorage.YellowKeyCard -- Your Item

--Ranks:
local Chairman = 255 -- Your rank number here
local President = 19 -- Your rank number here

--Scripts:

game.Players.PlayerAdded:Connect(function(Player) -- This line checks if a player has joined the server, and player is an argument.
print(Player.Name .. " Has Joined The Server") -- Printing out the player's name in the Developer Console, press F9 if you're on pc.
if Player:GetRankInGroup(GroupID) == President then -- Checks if the player's rank is President
wait(1)
local YellowKeyCardClone = YellowKeyCard:Clone() -- Set a variable to clone the keycard
YellowKeyCardClone.Parent = Player:WaitForChild("Backpack") -- Set the keycard parent to the player's backpack
local CheckKeyCardInBackpack = Player:WaitForChild("Backpack"):FindFirstChild("YellowKeyCardClone")
if CheckKeyCardInBackpack then
else
print("Cloning failed!")
end
elseif Player:GetRankInGroup(GroupID) == Chairman then -- Checks if the player's rank is Chairman
wait(1)
local BlueKeyCardClone = BlueKeyCard:Clone() -- Set a variable to clone the keycard
BlueKeyCardClone.Parent = Player:WaitForChild("Backpack")
local CheckKeyCardInBackpack = Player:WaitForChild("Backpack"):FindFirstChild("BlueKeyCardClone")
if CheckKeyCardInBackpack then
else
print("Cloning failed!")
end
else
print("Did not join the group or don't have the rank requirement.")
end
end)


I will be calm if someone helped me out, thanks!

0
I do can clone it using that script, but when I reset it is gone WINDOWS10XPRO 134 — 15d

0

The backpack always resets when the player's character loads, consider using it on the CharacterAdded signal.

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local BlueKeyCard = ReplicatedStorage:WaitForChild("BlueKeyCard")
local YellowKeyCard = ReplicatedStorage:WaitForChild("YellowKeyCard")

print(string.format("%s has joined the server!", player.Name))
local Backpack
repeat
wait()
until player:FindFirstChildWhichIsA("Backpack")
Backpack = player:FindFirstChildWhichIsA("Backpack")
local Rank = player:GetRankInGroup(7495829)
if Rank == 255 then
local success, response = pcall(function()
YellowKeyCard:Clone().Parent = Backpack
end)
if success == true then
return print(string.format("Keycard was given to %s", player.Name))
else
return error(response)
end
elseif Rank == 19 then
local success, response = pcall(function()
BlueKeyCard:Clone().Parent = Backpack
end)
if success == true then
return print(string.format("Keycard was given to %s", player.Name))
else
return error(response)
end
end
end)
end

0
I agree with this, but once again, it can fail. Use: 'player.Character or player.CharacterAdded:Wait()' because this will make the script wait for the character. KadenBloxYT 100 — 15d
0
How do I accept my own answer because I already fix it with and easier way and also, what's a pcall? WINDOWS10XPRO 134 — 14d
0
A pcall is something which will basically ignore a error if one happens, so if I do print(“Hello world!”) and wrap it in a pcall for it to fail some reason it will ignore the error and go on to the rest of the script without printing a error or stopping. Nicklaus_s 17 — 11d
0

I fixed it, my script is basic not too advanced because im still a beginner here's the script anyways:

--Script made by WINDOWS10XPRO

--[[
Title: KeyCardManagerScript
Goal: Gives keycard to specific rank in a group when they join the  server
Description: This script is made by WINDOWS10XPRO. It's an open source.     You can copy it if you want to.
]]--

--Variables:

local GroupID = 7495829 -- Your GroupID here
local ReplicatedStorage = game:GetService("ReplicatedStorage") -- ReplicatedStorage
local BlueKeyCard = ReplicatedStorage.BlueKeyCard -- Your Item
local YellowKeyCard = ReplicatedStorage.YellowKeyCard -- Your Item

--Ranks:
local Chairman = 255 -- Your rank number here
local President = 19 -- Your rank number here

--Scripts:

game.Players.PlayerAdded:Connect(function(Player) -- This line checks if a player has joined the server, and player is an argument.
print(Player.Name .. " Has Joined The Server") -- Printing out the player's name in the Developer Console, press F9 if you're on pc.
if Player:GetRankInGroup(GroupID) == President then -- Checks if the player's rank is President
wait(1)
local YellowKeyCardClone = YellowKeyCard:Clone() -- Set a variable to clone the keycard
YellowKeyCardClone.Parent = Player:WaitForChild("Backpack") -- Set the keycard parent to the player's backpack
local CheckKeyCardInBackpack = Player:WaitForChild("Backpack"):FindFirstChild("YellowKeyCardClone") -- Checks if the keycard is in the backpack
wait(8)
if CheckKeyCardInBackpack then -- If there is a keycard then it's successfully added
elseif not CheckKeyCardInBackpack then
print("Cloning failed!") -- else it's not but for some reason it says cloning failed but it actually success
end
if Character.Humanoid.Health == 0 then
wait(4.75)
YellowKeyCardClone.Parent = Player:WaitForChild("Backpack") -- I was forced to do this ;-; bruh
end

elseif Player:GetRankInGroup(GroupID) == Chairman then -- Checks if the player's rank is Chairman
wait(1)
local BlueKeyCardClone = BlueKeyCard:Clone() -- Set a variable to clone the keycard
BlueKeyCardClone.Parent = Player:WaitForChild("Backpack")
local CheckKeyCardInBackpack = Player:WaitForChild("Backpack"):FindFirstChild("BlueKeyCardClone")
wait(8)
if CheckKeyCardInBackpack then
elseif not CheckKeyCardInBackpack then
print("Cloning failed!")
end
if Character.Humanoid.Health == 0 then
wait(4.75)
BlueKeyCardClone.Parent = Player:WaitForChild("Backpack") -- I was forced to do this ;-; bruh
end
else
print("Did not join the group or doesn't met the group's rank requirement.")
end
end)
end)