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

Why doesnt my keydown script work with my lightsaber tool?

 script.Parent.Equipped:Connect (function(key)
	if (key == "F") then
		script.Parent.Part1111.Transparency = 0
		script.Parent.Part11111.Transparency = 0
	end
end)
  1. I attempted to change the script and catch the error, which turned out as a total fail.
  2. Script doesn't work in game or test mode.
  3. Script is located in Starter gui, in a tool
  4. It's a localscript 5.No errors

2 answers

Equipped doesn't have a "key" value, but it has a "mouse" value which can be used to get keyboard input.

local tool = script.Parent 
tool.Equipped:connect(function(mouse) -- indexing mouse from tool.equipped
	mouse.KeyDown:connect(function(key) --connecting keydown from the mouse already indexed
		if key == "f" then script.Parent.Part1111.Transparency = 0
script.Parent.Part11111.Transparency = 0
	end 
end)
end) 

Here's a script that you can hide the saber with: (hope it works)

local tool = script.Parent tool.Equipped:connect(function(mouse) -- indexing mouse from tool.equipped mouse.KeyDown:connect(function(key) --connecting keydown from the mouse already indexed if key == "q" then if script.Parent.Part1111.Transparency == 0 and script.Parent.Part11111.Transparency == 0 then wait (0.5) script.Parent.Part1111.Transparency == 1 script.Parent.Part11111.Transparency == 1

end

end) end)


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