From your comment on sal, I have configured it for you a different way. This way, you have a textbox and every time you enter text it looks for that player and awards them the card if they can be found and they don't already have it. If it's not exactly what you're envisioning, I'm sure you can configure it back with the errors that have been explained. Please take a look at this screenshot to see how your hierarchy should look.
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local sp = script.Parent
local reciever = sp:WaitForChild('TextBox')
local card = ReplicatedStorage:WaitForChild("Card")
local function player_hascard(player)
local inbackpack, equipped = player.Backpack:findFirstChild("Card"), player.Character:findFirstChild("Card")
if inbackpack or equipped then
return true
end
return false
end
local function return_player(player_name)
local found = false
for i,v in pairs(game.Players:GetPlayers()) do
if player_name == v.Name:lower() then
if not player_hascard(v) then
found = v
break
end
end
end
return found
end
reciever.Changed:Connect(function()
local find_player = return_player(reciever.Text:lower())
if find_player then
card:Clone().Parent = find_player.Backpack
end
end)
2 comments
don't use a looop
Is that was is making it not work?