#Admin Command script problem
1 messages · Page 1 of 1 (latest)
u sure
thats all the code?
no why
i alreadyy added it
but still not working
** You are now Level 1! **
why
comment suggests parameters are: target, itemName, quantity
you're processing them as: target, amount, itemName
ok
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
wait i will try
how i write the command
@small marsh
the correct foramt
format
still not working
i think that its because im not admin
maybe
and how i can be