Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can anyone help with with Giving people Tools from my inventory?

I want to add a command script (if it even is a script) to my game where I have some thing in my inventory and i give it to someone and is disappears from my inventory, like ones I've seen such as, ( :give/player/tool) or (:give player). I've tried a lot of other things to do it, but none work. So I've come here! If you someone could explain how i would go about doing this, that would be so appreciated! Thank you in advance!

2 comments

1

What have you tried? I understand that chat commands are hard, when using a lot of string manipulation, but we need to see what you tried.

0

Give us code then we can help you

1 answer

Here is some links and code to get you started when you give us some code i will happily edit this to an answer

First of spliting a string into a table to make it like this :give player tool or :give/player/tool

If you want to split it with slashes use this

--Splitstring by slash
function splitString(str)
  local args = {}
  for arg in string.gmatch(str,"./+") do
    table.insert(args,arg)
  end
  return args
end

or if you want to split it with spaces

--Splitstring by space
function splitString(str)
  local args = {}
  for arg in string.gmatch(str,"%S+") do
    table.insert(args,arg)
  end
  return args
end

if you don't want to use slashes or spaces to split check this wikipage

now we can get the arguments like this splitString("Something Just Like This")[1] returns Something [2] returns Just and soo on

to put the tool in another players inventory we would want to use the Parent property

for example game.Workspace.Model.Part.Parent = workspace puts the Part in workspace

Wikipages

String Patterns

Parent Property

Table Indexing

Chat Commands

if you have any questions or you did not understand something comment and i will edit this bible text to make you understand

This discussion is preserved as it was. New answers, comments, and votes are closed.