This is a donation script in which the player can give their intended target items and only have to do that by entering the first few letters of the name, What am I doing wrong?
local rStorage = game:GetService("ReplicatedStorage")
local shop = rStorage:WaitForChild("GiveFood")
function event(Player,Target, Item)
end
function getplr(name)
local returned = {""}
for i,v in pairs (game.Players:GetPlayers()) do
if v.Name:sub(1,name:len()):lower() == name:lower() then
table.Insert(returned, v)
end
end
return returned
end
function event(Player,Target, Item)
local q = getplr(string.sub(Target,1))
print(q)
if q then
if #q == 1 then
local q = q[1]
local tool = game:GetService("ServerStorage").Ingredients[Item]:Clone()
tool.Parent = q.Backpack
Player.Character[Item]:Destroy()
end
end
end
shop.OnServerEvent:connect(event)

2 comments
whats the error? and why do you have an empty function event() at the top?
that was an mistake when i paste it in, anyway the error is that the table is nil even though ive inserted it