I want to give a tool to a person who’s user ID is in a trello board.
I believe the issue could be on the lines where I put --Mark. However I cannot figure out what my issue here could be.
This code works with another thing such as plr:Kick() however the tool cloning is not working.
I have looked everywhere and asked a number of people however not here.
local API = require(game.ServerScriptService:WaitForChild("TrelloAPI"))
local BanBoardID = API:GetBoardID("Licenses")
local BanListID = API:GetListID("Firearms",BanBoardID)
local Tool = script.FirearmsLicense
function checkCurrentPlayersForBan()
while wait(10) do
local BanCards = API:GetCardsInList(BanBoardID)
for _, Player in pairs(game.Players:GetChildren()) do
for _, Card in pairs(BanCards) do
if string.find(Card.name, Player.UserId) then
local Backpack = Player:WaitForChild("Backpack")
local ToolClone = Tool:Clone()
Tool.Parent = Backpack
end
end
end
end
end
spawn(checkCurrentPlayersForBan)
game.Players.PlayerAdded:Connect(function(plr)
local BanCards = API:GetCardsInList(BanListID)
for _, Card in pairs(BanCards) do
if string.find(Card.name, plr.UserId) then
local Backpack = plr:WaitForChild("Backpack") -- Mark
local ToolClone = Tool:Clone() -- Mark
Tool.Parent = Backpack -- Mark
print("Successfully completed the mission")
end
end
end)
You have to add a CharacterAdded event to wait for the character to load in and then parent the tool by doing:
Tool.Parent = game.Players[plr.Name].Backpack
Isn’t working. I’m not very experienced with events is this correct?
local API = require(game.ServerScriptService:WaitForChild("TrelloAPI"))
local BanBoardID = API:GetBoardID("Licenses")
local BanListID = API:GetListID("Firearms",BanBoardID)
local Tool = script.FirearmsLicense
function checkCurrentPlayersForBan()
while wait(10) do
local BanCards = API:GetCardsInList(BanBoardID)
for _, Player in pairs(game.Players:GetChildren()) do
for _, Card in pairs(BanCards) do
if string.find(Card.name, Player.UserId) then
local Backpack = Player:WaitForChild("Backpack")
local ToolClone = Tool:Clone()
Tool.Parent = Backpack
end
end
end
end
end
spawn(checkCurrentPlayersForBan)
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(chr)
local BanCards = API:GetCardsInList(BanListID)
for _, Card in pairs(BanCards) do
if string.find(Card.name, plr.UserId) then
local ToolClone = Tool:Clone()
Tool.Parent = game.Players[plr.Name].Backpack
end
end
end)
end)
It works for me, so the problem most likely must be with the values in your for loop or if statement.
Try put a print inside the if statement. If that doesn’t print anything, it’s most likely with the Card.name. I don’t know what properties Card has, but if it has a name property, try that with Card.Name.
Also, I noticed a few things. Do ToolClone.Parent instead of Tool.Parent and I think it would be best if you waited for the tool inside the script: local Tool = script:WaitForChild("FirearmsLicense", 1)