<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.starfall.wtf/index.php?action=history&amp;feed=atom&amp;title=Intro_to_Scripting%3A_Make_an_Invisibility_Tool</id>
	<title>Intro to Scripting: Make an Invisibility Tool - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.starfall.wtf/index.php?action=history&amp;feed=atom&amp;title=Intro_to_Scripting%3A_Make_an_Invisibility_Tool"/>
	<link rel="alternate" type="text/html" href="https://wiki.starfall.wtf/index.php?title=Intro_to_Scripting:_Make_an_Invisibility_Tool&amp;action=history"/>
	<updated>2026-07-28T17:09:17Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.starfall.wtf/index.php?title=Intro_to_Scripting:_Make_an_Invisibility_Tool&amp;diff=411&amp;oldid=prev</id>
		<title>PRG: Created page with &quot;{{CatUp|Tutorials}} {{ScriptTutorial|Advanced|Lua}} __TOC__  ==Introduction== This tutorial is for people who wish to learn more about creation of tools, or who wish to add an invisibility tool to their map. It contains a basic invisibility script, without fading of characters.  ==How the Tool Works== The invisibility tool is a HopperBin object so it will be able to be selected. It sets the &#039;&#039;Transparency&#039;&#039; values of all the player&#039;s RBX....&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.starfall.wtf/index.php?title=Intro_to_Scripting:_Make_an_Invisibility_Tool&amp;diff=411&amp;oldid=prev"/>
		<updated>2024-12-10T12:46:02Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{CatUp|Tutorials}} {{ScriptTutorial|Advanced|Lua}} __TOC__  ==Introduction== This tutorial is for people who wish to learn more about creation of tools, or who wish to add an invisibility tool to their map. It contains a basic invisibility script, without fading of characters.  ==How the Tool Works== The invisibility tool is a &lt;a href=&quot;/index.php/RBX.lua.HopperBin_(Object)&quot; title=&quot;RBX.lua.HopperBin (Object)&quot;&gt;HopperBin&lt;/a&gt; object so it will be able to be selected. It sets the &amp;#039;&amp;#039;Transparency&amp;#039;&amp;#039; values of all the player&amp;#039;s RBX....&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{CatUp|Tutorials}}&lt;br /&gt;
{{ScriptTutorial|Advanced|Lua}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
This tutorial is for people who wish to learn more about creation of tools, or who wish to add an invisibility tool to their map. It contains a basic invisibility script, without fading of characters.&lt;br /&gt;
&lt;br /&gt;
==How the Tool Works==&lt;br /&gt;
The invisibility tool is a [[RBX.lua.HopperBin (Object)|HopperBin]] object so it will be able to be selected. It sets the &amp;#039;&amp;#039;Transparency&amp;#039;&amp;#039; values of all the player&amp;#039;s [[RBX.lua.Part (Object)|parts]] to 1, which is completely transparent. To make this work in multiplayer, the script to make the player transparent has to be in the player, not the player&amp;#039;s [[RBX.lua.Backpack (Object)|backpack]]. To this end, the true invisibility script is made to not work in the player&amp;#039;s backpack, and is copied into the player; when the player becomes visible again, it is removed. A second script in the backpack copies the script to the player when it is activated.&lt;br /&gt;
&lt;br /&gt;
==Invisibility==&lt;br /&gt;
The first script to be created is a script for hiding a model. This script can be copied into the player to make the player invisible, and can have a varied amount of time of invisibility.&lt;br /&gt;
&lt;br /&gt;
===Tutorial===&lt;br /&gt;
As the script will only be two places, in a [[RBX.lua.HopperBin (Object)|HopperBin]] and in a player, the script can deal with just those cases. The script should only run if it is in the player. If it is in the player, the parent of the script will have a class name of &amp;quot;[[RBX.lua.Model (Object)|Model]]&amp;quot;. To check this, the script can have the &amp;quot;if&amp;quot; statement:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if (script.Parent.className == &amp;quot;Model&amp;quot;) then&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the script is in the model, it should make it invisible. To do this, the script must find all the player&amp;#039;s model&amp;#039;s children. The function &amp;#039;&amp;#039;children()&amp;#039;&amp;#039; returns an array (table) of children of the object that called it. The script can assign a variable to the table produced.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
modelChildList = script.Parent:children()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, the script must make the player&amp;#039;s children invisible. A &amp;quot;for&amp;quot; loop can do the job.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for p = 1, #modelChildList do -- Make the player invisible&lt;br /&gt;
	if (modelChildList[p].className == &amp;quot;Part&amp;quot;) then -- Only work on bricks&lt;br /&gt;
		modelChildList[p].Transparency = 1 -- Transparent&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Once the player is invisible, the script should wait for a pre-defined time. This time can either be hard-coded into the script or transmitted by the activation script. The hard-coded approach can be accomplished by:&lt;br /&gt;
&lt;br /&gt;
 wait(&amp;#039;&amp;#039;Invisibility Time&amp;#039;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
Where &amp;#039;&amp;#039;Invisibility Time&amp;#039;&amp;#039; is the number of seconds to be invisible. The transmitted approach uses a [[RBX.lua.NumberValue (Object)|NumberValue]] object. It can be implemented as:&lt;br /&gt;
&lt;br /&gt;
 wait(script:findFirstChild(&amp;quot;&amp;#039;&amp;#039;NumberValue Name&amp;#039;&amp;#039;&amp;quot;).Value)&lt;br /&gt;
&lt;br /&gt;
Where &amp;#039;&amp;#039;NumberValue Name&amp;#039;&amp;#039; is a [[string]] representing the name of the number. A good name is &amp;quot;InvisibilityTime&amp;quot;. After the invisibility wait time is over, the previous for-loop can be modified to make the player visible.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for p = 1, #modelChildList do -- Make the player visible&lt;br /&gt;
	if (modelChildList[p].className == &amp;quot;Part&amp;quot;) then -- Only work on bricks&lt;br /&gt;
		modelChildList[p].Transparency = 0 -- Solid&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After this is done, the script is useless. It&amp;#039;s time to get rid of it. To do this, the script&amp;#039;s Parent value can be set to &amp;#039;&amp;#039;&amp;#039;nil&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
script.Parent = nil&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
If the script has been created exactly according to directions, or is just copied, then it will have the following code (with one or two changes): &amp;#039;&amp;#039;Note: the name of this script is &amp;quot;Fade&amp;quot;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
print(&amp;quot;Fading script loaded&amp;quot;)&lt;br /&gt;
if (script.Parent.className == &amp;quot;Model&amp;quot;) then -- Only deals with player characters, so no need for extra&lt;br /&gt;
&lt;br /&gt;
	modelChildList = script.Parent:children()&lt;br /&gt;
&lt;br /&gt;
	for p = 1, #modelChildList do -- Make the player invisible&lt;br /&gt;
		if (modelChildList[p].className == &amp;quot;Part&amp;quot;) then&lt;br /&gt;
			modelChildList[p].Transparency = 1 -- Invisible&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	wait(script:findFirstChild(&amp;quot;InvisibilityTime&amp;quot;).Value)&lt;br /&gt;
&lt;br /&gt;
	for p = 1, #modelChildList do -- Make player visible&lt;br /&gt;
		if (modelChildList[p].className == &amp;quot;Part&amp;quot;) then&lt;br /&gt;
			modelChildList[p].Transparency = 0 -- Visible&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	script.Parent = nil -- Remove the (now useless) script from the game&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Activation==&lt;br /&gt;
The previous script makes a player invisible. This script activates the other script.&lt;br /&gt;
&lt;br /&gt;
===Tutorial===&lt;br /&gt;
First, the script needs to know when it is selected, and with what [[RBX.lua.Mouse (Object)|Mouse]] object. This will let it know when to activate the invisibility. To this end, a function is added:&lt;br /&gt;
&lt;br /&gt;
 function onSelected(mouse) -- When the weapon is selected, make the script recognize clicks&lt;br /&gt;
 	&amp;#039;&amp;#039;setCursor&amp;#039;&amp;#039;(mouse) -- Make the mouse indicate readiness. This is currently a dummy.&lt;br /&gt;
 	mouse.Button1Down:connect(function() &amp;#039;&amp;#039;onButton1Down&amp;#039;&amp;#039;(mouse) end) -- Make the activation script be called when there is a click.&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
This will make &amp;#039;&amp;#039;onButton1Down&amp;#039;&amp;#039;() be called with an argument (input) of the mouse name whenever the mouse clicks while the tool is selected. &amp;#039;&amp;#039;setCursor&amp;#039;&amp;#039; is a dummy function (it will be added later, but it is only a stylistic thing). Next, the &amp;#039;&amp;#039;onButton1Down&amp;#039;&amp;#039; function should be added:&lt;br /&gt;
&lt;br /&gt;
 enabled = true -- A boolean value, made to stop multiple invisibilities&lt;br /&gt;
 invisibilityTime = 8 -- Time the person will be invisible&lt;br /&gt;
 reloadTime = 4 -- Additional time to reload&lt;br /&gt;
 &lt;br /&gt;
 function onButton1Down(mouse)&lt;br /&gt;
 	if enabled then&lt;br /&gt;
 		enabled = false -- Stop multiple invisibilities&lt;br /&gt;
 		&amp;#039;&amp;#039;setCursor&amp;#039;&amp;#039;(mouse) -- Not ready anymore&lt;br /&gt;
 		playerScript = script.Parent.&amp;#039;&amp;#039;Fade&amp;#039;&amp;#039;:clone() -- Copy the fading script&lt;br /&gt;
 		playerScript.Parent = game.Players.LocalPlayer.Character -- and place it in the player&lt;br /&gt;
 &lt;br /&gt;
 		scriptTimeOut = Instance.new(&amp;quot;NumberValue&amp;quot;) -- Give it a time before becoming visible again&lt;br /&gt;
 		scriptTimeOut.Name = &amp;quot;InvisibilityTime&amp;quot; -- This name must be coded into the other script&lt;br /&gt;
 		scriptTimeOut.Value = invisibilityTime -- Time to stay invisible&lt;br /&gt;
 		scriptTimeOut.Parent = playerScript&lt;br /&gt;
 &lt;br /&gt;
 		wait(reloadTime + invisibilityTime) -- Wait for a proper reload time&lt;br /&gt;
 		enabled = true -- Ready again&lt;br /&gt;
 	end&lt;br /&gt;
 	&amp;#039;&amp;#039;setCursor&amp;#039;&amp;#039;(mouse) -- Set apropriate cursor&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;setCursor&amp;#039;&amp;#039; is still a dummy (not made yet). This script activates the other script (named &amp;quot;&amp;#039;&amp;#039;Fade&amp;#039;&amp;#039;&amp;quot; here), and gives it a value to use as an invisibility time. With all the rest done, it&amp;#039;s time to make &amp;#039;&amp;#039;setCursor&amp;#039;&amp;#039; a real function:&lt;br /&gt;
&lt;br /&gt;
 function setCursor(mouse)&lt;br /&gt;
 	if enabled then&lt;br /&gt;
 		mouse.Icon = &amp;quot;rbxasset://textures\\ArrowCursor.png&amp;quot;&lt;br /&gt;
 	else&lt;br /&gt;
 		mouse.Icon = &amp;quot;rbxasset://textures\\ArrowFarCursor.png&amp;quot;&lt;br /&gt;
 	end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;mouse.Icon&amp;#039;&amp;#039; is the image used for the cursor. &amp;quot;&amp;#039;&amp;#039;rbxasset://textures\\ArrowCursor.png&amp;#039;&amp;#039;&amp;quot; and &amp;quot;&amp;#039;&amp;#039;rbxasset://textures\\ArrowFarCursor.png&amp;#039;&amp;#039;&amp;quot; are standard cursor images available to Roblox clients. &amp;#039;&amp;#039;setCursor&amp;#039;&amp;#039; Changes the cursor to an appropriate image based on the &amp;#039;&amp;#039;enabled&amp;#039;&amp;#039; boolean.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
If the script has been made exactly according to the tutorial, or was just copied, it will look like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
print(&amp;quot;Invisibility hopper script loaded&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
enabled = true&lt;br /&gt;
invisibilityTime = 8 -- Time the person will be invisible&lt;br /&gt;
reloadTime = 4 -- Additional time to reload&lt;br /&gt;
&lt;br /&gt;
function setCursor(mouse)&lt;br /&gt;
	if enabled then&lt;br /&gt;
		mouse.Icon = &amp;quot;rbxasset://textures\\ArrowCursor.png&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		mouse.Icon = &amp;quot;rbxasset://textures\\ArrowFarCursor.png&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function onButton1Down(mouse)&lt;br /&gt;
	if enabled then&lt;br /&gt;
		enabled = false&lt;br /&gt;
		setCursor(mouse) -- Not ready anymore&lt;br /&gt;
		playerScript = script.Parent.Fade:clone() -- Copy the fading script&lt;br /&gt;
		playerScript.Parent = game.Players.LocalPlayer.Character -- Place it in the player&lt;br /&gt;
		scriptTimeOut = Instance.new(&amp;quot;NumberValue&amp;quot;) -- Give it a time before becoming visible again&lt;br /&gt;
		scriptTimeOut.Name = &amp;quot;InvisibilityTime&amp;quot;&lt;br /&gt;
		scriptTimeOut.Value = invisibilityTime&lt;br /&gt;
		scriptTimeOut.Parent = playerScript&lt;br /&gt;
&lt;br /&gt;
		wait(reloadTime + invisibilityTime) -- Wait for a proper reload time&lt;br /&gt;
		enabled = true -- Ready again&lt;br /&gt;
	end&lt;br /&gt;
	setCursor(mouse) -- Set apropriate cursor&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function onSelected(mouse) -- When the weapon is selected, make the script recognize clicks&lt;br /&gt;
	print(&amp;quot;Invisibility selected&amp;quot;)&lt;br /&gt;
	setCursor(mouse) -- Make the mouse indicate readiness&lt;br /&gt;
	mouse.Button1Down:connect(function() onButton1Down(mouse) end)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
script.Parent.Selected:connect(onSelected)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting Tutorials]]&lt;br /&gt;
[[Category:Player Tools]]&lt;/div&gt;</summary>
		<author><name>PRG</name></author>
	</entry>
</feed>