Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script is not recognizing or finding the intended target?

Asked by 5 years ago

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)
0
whats the error? and why do you have an empty function event() at the top? chomboghai 2044 — 5y
0
that was an mistake when i paste it in, anyway the error is that the table is nil even though ive inserted it RukyrZus 5 — 5y

Answer this question