Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What is vCharacter and waitforChild(Parent, instance)?

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 comments

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.

0

That's what I'm trying to do XD

1 answer

✓ Accepted answer

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.

3 comments

0

Oh I know that, But what REALLY confuses me is 'vCharacter, vHumanoid, vTorso' the usage of Parent, Instance >:l

0

They are just passing parameters. It's waiting for a "Torso" in the vCharacter model and a "Humanoid" in the vCharacter model.

0

Oh. Mkay then :D

This discussion is preserved as it was. New answers, comments, and votes are closed.