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

How exactly do morphs work? And what is this 'i, b in pairs' function?

Asked by
Smunkey 95
8 years ago

I have recently been trying to make a morph from scratch by dissecting lots of free model morphs to try and find out how they work. However I am getting stuck on a few things.

So far it seems they copy and paste parts of the morph model into the player who activates them, and the copy-pasted parts override the existing parts of said player. Is this correct or is it more complicated than that?

Another thing is the morph scripts I've been reading have a common occurrence of this 'for i,b in pairs () do' thingy, example here

    BodyParts = hit.Parent:GetChildren()
        for i,b in pairs(BodyParts) do
            if (b.className == "Humanoid") then
                CanMorph = true
            end

What is up with that?

1 answer

Log in to vote
0
Answered by 8 years ago

This script is literally, going through everything in the hit.Parent, and IF one of them is a Humanoid, CanMorph is true. Its to make sure whatever hit it, is an actual player, and not like a part, or union or w/e.


for i,v in pairs(hit.Parent:GetChildren()) do if v:IsA("Humanoid" then CanMorph = true end -- v is each part of (hit.Parent:GetChildren()) -- i is the number of 'things' found.
0
So if I where to convert it into a GUI button I could ignore the pairs completely? Smunkey 95 — 8y
0
uhh, i guess so ConnorVIII 448 — 8y
0
Thanks, Connor! Smunkey 95 — 8y
0
no prob, accept my answer/thumbs up! ConnorVIII 448 — 8y
0
I don't have enough reputation to upvote :( Smunkey 95 — 8y
Ad

Answer this question