What I am trying to do here is when a tool is equipped and left click is clicked, if the cursor is aiming at fixp, zwire, rwire or gwire, some parts' transparencies should change. This is a localscript and i put it in the tool which is supposed to be equipped:
--Variables local tool = script.Parent local fixwire = game.Workspace.bluewirefix local fixp = game.Workspace.fixp local Player = game:GetService("Players").LocalPlayer local Mouse = Player:GetMouse() local Target = Mouse.Target local zwire = game.Workspace.zwire local gwire = game.Workspace.gwire local rwire = game.Workspace.rwire --Script tool.Equipped:Connect(function(Mouse) Mouse.Button1Down:Connect(function() if Target == fixp or Target == zwire or Target == gwire or Target == rwire then zwire.Transparency = 1 fixwire.Transparency = 0 print("g") end end) end)
No errors in output are shown. What am I doing wrong? ;-;
You need to say local Target = Mouse.Target
on line 16, not on line 7. On line 7 you're getting the mouse target when the script loads up - when Mouse.Target changes, your Target variable isn't updated.