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 print("Succesfully added!") 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 print("Succesfully added!") 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!
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") local function OnPlayerAdded(player) print(string.format("%s has joined the server!", player.Name)) player.CharacterAdded:Connect(function(Character) 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
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. Player.CharacterAdded:Connect(function(Character) 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 print("Succesfully 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 print("Succesfully added!") 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)
you need to use CharacterAdded
it's at line 36. Hope this helps :D