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

Is the debounce on this script(visible) being used correctly?

This is my script:

--Teleport

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local char = player.Character
local visible = true
--Parts
local head = char.Head
local torso = char.Torso
local larm = char["Left Arm"]
local rarm = char["Right Arm"]
local lleg = char["Left Leg"]
local rleg = char["Right Leg"]
--Functions
function makeInvisible(object)
	local objectChildren = object:GetChildren()
	for i = 1,#objectChildren do
		for v = 0,1,0.001 do
			if objectChildren[i]:IsA("Part") then
				objectChildren[i].Transparency = v
				elseif(objectChildren[i]:IsA("Hat")) then
				objectChildren[i].Handle.Transparency = v
			end
		end
	end
end

function makeVisible(object)
	local objectChildren = object:GetChildren()
	for i = 1,#objectChildren do
	for v = 1,0,0.001 do
			if objectChildren[i]:IsA("Part") then
				objectChildren[i].Transparency = v
			elseif(objectChildren[i]:IsA("Hat")) then
				objectChildren[i].Handle.Transparency = v
			end
		end
	end
end

--
mouse.KeyDown:connect(function(key)
	if key == "z" and visible == true then
		makeInvisible(char)	
		visible = false
		end
		if key == "x" and visible == false then
			visible = true
			makeVisible(char)
	end
end)

The object of the script is to make a character invisible when the key "z" is pressed. The character is supposed to become visible when the key "x" is pressed. Please explain what is wrong.

2 comments

1

Line 31, -0.001, not positive, if you're going from 1 to 0.

0

Oh your right

1 answer

✓ Accepted answer

It took a while to identify your mistake but here it is:

At code line 51, take out the code end) and ident the rest of the if code.

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