I use the key command/script, it did not work, am I missing anything?
Script
local key = "e"
mouse.KeyDown:connect(function(k)
if k:lower() == key then
if mouse.Target then
if mouse.Target:FindFirstChild("item") then
script.Parent.Transparency = 0.5
end
Fixed Script
local plr = game.Players.LocalPlayer
local key = "e"
local mouse = plr:GetMouse()
mouse.KeyDown:connect(function(k)
if k:lower() == key then
if mouse.Target then
if mouse.Target:FindFirstChild("item") then
script.Parent.Transparency = 0.5
end
end
end
end)
Fix version
-- Place in StarterPlayerScripts
local UserInputService = game:GetService("UserInputService")
local plr = game:GetService("Players").LocalPlayer
local mouse = plr:GetMouse()
UserInputService.InputBegan:Connect(function(input, gpe) -- input beginning
if gpe then return end
-- if the player is processing text (like chatting! and pressing key, end the function
if input.KeyCode == Enum.KeyCode.E then -- if the key is E
if mouse.Target and mouse.Target:FindFirstChild("item") then
-- code
workspace.Part666.Transparency = 0.5
end
end
end)
Still did not work why? It's a local script in StarterPlayerScripts
Please help!

2 comments
you are missing 3 ends
by the way KeyDown is deprecated you could use inputbegan from userinputservice ill make an answer rn