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

Why does my invisibility tool not work properly?

I'm trying to make an invisibility tool that makes your entire body turn invisible, then turn visible again, but for some reason it's not functioning how I would like.

local tool = script.Parent
local debounce = false

function onButton1Down(mouse)
if debounce == false then
debounce = true
	local player = game.Players.LocalPlayer
	for _,m in ipairs(player.Character:GetChildren()) do
		if m.className == "Hat" then
			m.Handle.Transparency = 1
		end
		if m.className == "Part" then
			m.Transparency = 1
		end
		wait(1)
			for _,mm in ipairs(m:GetChildren()) do
				if mm.ClassName == "Decal" then
					mm.Transparency = 1
				end
				wait(5)
				if mm.ClassName == "Decal" then
					mm.Transparency = 0
				end
			end
			if m.className == "Hat" then
				m.Handle.Transparency = 0
			end
			if m.className == "Part" then
				m.Transparency = 0
			end
		end
		debounce = false
	end
end


function onSelected(mouse)
	mouse.Icon = "rbxasset://textures\\ArrowCursor.png"
	mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end

tool.Selected:connect(onSelected)

2 comments

0

Is there any output errors, or how is not acting correctly?

0

It put out "Selected is not a valid member of Tool".

1 answer

Using wiki.roblox.com we can see the members of a "tool,

tool.Selected:connect(onSelected)

is not a valid member becuase you would need to use

Tool.Equipped (when the tool is selected and the mouse is clicked) or Tool.Activated (when the tool is selected)

1 comment

0

I fixed the error, but now only my head only turns invisible instead of my entire body.

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