Hello i am trying to achieve Click detecting on parts without using Click Detector but when i play test this code Target is always nil and isnt changing
can smn tell me why this happens and how can make my mouse tell the target
-- This is an example Lua code block
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Target = Mouse.Target
Mouse.Move:Connect(function()
print(Target)
end)
Assuming this is a local script (If it’s not, then you can’t access the player mouse from a localscript):
You are saving the target as a variable at the start, meaning that when you print Target you’re just printing your initial changed variable which is static. When you save it as a variable, you’re not saving the changing part of it. If you would like to print the target, just print Mouse.Target in your Mouse.Move function.
The issue is that you are using the same target from the beginning of the script. You should set target each time the mouse moves and print it afterwards.