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

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

Asked by 6 years ago

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!

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. hiimgoodpack 2009 — 6y
0
Give us code then we can help you Filipalla 504 — 6y

1 answer

Log in to vote
0
Answered by
Filipalla 504 Moderation Voter
6 years ago
Edited 6 years ago

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

Ad

Answer this question