So I’m a new developer and I was looking at some free models. I found this flying carpet giver and I wanted to learn what some of the scripts mean in this script. Now this may take awhile but can someone please explain what this script means? I have tried to rewrite the script to help me get a better understanding but I still can’t get a grip on it. I have also looked up some of the codes I especially don’t understand, but it is too hard to find a simple answer. If you don’t feel like spending time on this that’s fine, I would appreciate it if someone would give some tips and tricks to get better at scripting. I did start 3 days ago so don’t expect a lot out of me and I did watch the whole Alvin Blox YouTube tutorial and a little bit of the dev kings too. Thank you for your time and the script I don’t understand is below this message.
function getPlayer(humanoid)
local players = game.Players:children()
for i = 1, #players do
if players[i].Character.Humanoid == humanoid then return players[i] end
end
return nil
end
function onTouch(part)
local human = part.Parent:findFirstChild(“Humanoid”)
if (human ~= nil) and debounce == false then
debounce = true
local player = getPlayer(human)
if (player == nil) then return end
local clone = game:GetService(“InsertService”):LoadAsset(225921000):GetChildren()[1]
clone.Handle.Anchored = false
clone.Parent = player.Backpack
wait(2)
debounce = false
end
end
script.Parent.Touched:connect(onTouch)```