#Admin Command script problem

1 messages · Page 1 of 1 (latest)

vernal ember
#

i need help when im using the command in the chat its not working example :
when im using this /give plrName amount itemName
nothing happening pls help

vernal ember
small marsh
#

bc I saw the } was missing

#

at end

#

xD

#

and tough it might not work

#

bc it error

vernal ember
#

i alreadyy added it

vernal ember
vernal ember
#

someone help pls

limpid slateBOT
#

studio** You are now Level 1! **studio

small marsh
#

ah

#

I see

#

why

vernal ember
#

why

small marsh
#

comment suggests parameters are: target, itemName, quantity

#

you're processing them as: target, amount, itemName

vernal ember
#

o

#

are you sure?

small marsh
#

maybe not

#

wait I didnt send full

vernal ember
#

ok

small marsh
#

give = function(speaker,...) --target, amount, itemName
    local args = {...}
    local targetName = args[1]
    local amountStr = args[2]
    local amount = tonumber(amountStr)
    
    table.remove(args,1)
    table.remove(args,1)
    local itemNamePartial = table.concat(args, " ")

    local closestMatch,targetPlayer = "",nil
    local target = game.Players:FindFirstChild(targetName)
    if target then targetPlayer = target
    else
        for _,v in next,game.Players:GetPlayers() do
            local match = string.match(v.Name:lower(),targetName:lower())
            if match then
                if #match>=#closestMatch then
                    closestMatch = match
                    targetPlayer = v
                end
            end
        end
    end
    if not targetPlayer then
        rep.Events.Notify:FireClient(speaker,"Can't find that player!",colorData.badRed,3)
        return
    end

    closestMatch = ""
    local closestItem = nil
    for _,v in next,game.ServerStorage.Items:GetChildren() do
        local match = string.match(v.Name:lower(),itemNamePartial:lower())
        if match and #match >= #closestMatch then
            closestMatch = match
            closestItem = v
        end
    end
    if not closestItem then
        rep.Events.Notify:FireClient(speaker,"Can't find that item...",colorData.goodGreen,3)
        return
    end
    local itemName = closestItem.Name

    if not amount then
        rep.Events.Notify:FireClient(speaker,"Incorrect format.. say  /give plrName amount itemName",colorData.badRed,6)
        return
    end

    for i=1,amount do
        GiveItemToPlayer(itemName,targetPlayer)
    end
    
    if targetPlayer ~= speaker then
        rep.Events.Notify:FireClient(targetPlayer,speaker.Name.." gave you "..amount.." "..itemName,colorData.goodGreen,3)
    end
    rep.Events.Notify:FireClient(speaker,"You gave "..targetPlayer.Name.." "..amount.." ".. itemName,colorData.goodGreen,3)
end

vernal ember
#

wait i will try

#

how i write the command

#

@small marsh

#

the correct foramt

#

format

small marsh
#

wdym

#

look at

#

args

#

from comments

vernal ember
small marsh
#

idk

#

then

vernal ember
small marsh
#

maybe

vernal ember
#

and how i can be

small marsh
#

idk

#

I go sleep