Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why doesnt my keydown script work with my lightsaber tool?

Asked by 6 years ago
Edited 6 years ago
 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

Log in to vote
0
Answered by 6 years ago

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) 
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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)


Answer this question