Yo Im really confused just by looking at this script and I was wondering if anyone can help me try and help me understand this and whats going on. Especially with the value[1], value[2], value[3]. How does that work???
local tool=script.Parent
local handle=tool.Handle
local remotefunction=tool.RemoteFunction
local debris=game:GetService("Debris")
function remotefunction.OnServerInvoke(player,command,value)
if command=="protect" then
if value[2] then
local currentvest=value[1]:FindFirstChild("VestArmour")
if currentvest then
currentvest:Destroy()
end
local vest=Instance.new("Hat")
vest.Name="VestArmour"
handle:Clone().Parent=vest
vest.AttachmentPos=Vector3.new(0,2,0.05)
vest.Parent=value[1]
local ratio=value[2].Health/value[2].MaxHealth
value[2].MaxHealth=100+value[3]
value[2].Health=(100+value[3])*ratio
tool.Handle.Transparency=1
wait(2)
tool.Handle.Transparency=0
end
end
end
In this script “Value” is a table, and like any table you can index it like this table[1]. The number or thing in brackets is the key, what is outputted is the value. Here’s an example of what that does on arrays.
local Array = {"Dogs", "Animals", "Cats", "Sandwhich"}
print(Array[1]) -- Would print "Dogs"
Here’s what it does on dictionaries:
local Dictionary = {
This = "Dogs",
That = "Cats",
TheThird = "Animal"
}
print(Dictionary[This]) -- Prints "Dogs"
What do you mean? Value is a table, player and command are variables sent from the remoteFunction. It also depends on what is actually written inside of the table, you can only get values from inside the table indexing a table.