Hello, I'm fairly new to scripting. I was testing out things and couldn't figure out how to make something happen while left click is held down. I am trying to make x-ray goggles. I want it to be green and halfway transparent while the left click is held down and normal when not. This is what I have so far. As you can see, right now if you click once and changes for 20 secs and reverts back to normal.
local Door = game.Workspace.Doory local Tool = script.Parent Tool.Equipped:Connect(function(Mouse) Mouse.Button1Down:Connect(function() Door.Transparency = 0.5 Door.BrickColor = BrickColor.new("Camo") wait(20) Door.Transparency = 0 Door.BrickColor = BrickColor.new("Dark stone grey") end) end)
Any help would be appreciated.
I'm not sure if it will work, but try to create a mouse variable:
local Door = game.Workspace.Doory local Tool = script.Parent local mouse = game.Players.LocalPlayer:GetMouse Tool.Equipped:Connect(function(Mouse) mouse.Button1Down:Connect(function() Door.Transparency = 0.5 Door.BrickColor = BrickColor.new("Camo") wait(20) Door.Transparency = 0 Door.BrickColor = BrickColor.new("Dark stone grey") end) end)
try to put that script in a script location if possible and try again