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

What is vCharacter and waitforChild(Parent, instance)?

Asked by 9 years ago

Another Question :D I have someone who is VERY generous and told me to get this Free Model and look at the scripts, and I did, and I came across two things, 'Vcharacter' which made no sense, the Parent of the script, which is the Tool itself, is not represented in that matter in the script, take a look

local vCharacter = script.Parent 
local vTorso = waitForChild(vCharacter, "Torso")
local vHumanoid = waitForChild(vCharacter, "Humanoid")

I do, know what 'WaitForChild' is. And also this,

local function waitForChild(parent, instance)
    while parent:FindFirstChild(instance) == nil do 
        wait()
    end 
    return parent[instance]
end

What is this? >:l

2
You should maybe learn to script... You realize that there isn't "one way" to do this, and the name is as much an authorial choice as "red" vs "scarlet"? `vCharacter` is plainly `script.Parent`. BlueTaslem 18071 — 9y
0
That's what I'm trying to do XD offbeatpizzalives123 105 — 9y

1 answer

Log in to vote
2
Answered by
RedCombee 585 Moderation Voter
9 years ago

I don't remember anything about the vCharacter, vTorso, or vHumanoid, but WaitForChild() is a method that literally waits for a child. Say, if there's something that is inserted into a character like a tool, you could use it like such:

tool = Character:WaitForChild("Gun")

If there was a gun that you had to make sure was there for your script, you could use this instead of:

tool = Character.Gun

To guarantee your script won't error.

0
Oh I know that, But what REALLY confuses me is 'vCharacter, vHumanoid, vTorso' the usage of Parent, Instance >:l offbeatpizzalives123 105 — 9y
0
They are just passing parameters. It's waiting for a "Torso" in the `vCharacter` model and a "Humanoid" in the `vCharacter` model. BlueTaslem 18071 — 9y
0
Oh. Mkay then :D offbeatpizzalives123 105 — 9y
Ad

Answer this question