I’m making a system to create an aim-lock for my futuristic laser rifle.
To do this, I need to detect if the player’s mouse is hovering over one of the indicators on players and NPC’s.
I have tried a few methods, but none have worked for me. I have been using an invisible ImageButton for the detection and also tried the reticle label itself or increasing the size of of the button. I’ve tried MouseEnter, InputBegan, etc, but none seem to have worked.
Yes, the GUI is in PlayerGui and set to the Adornee of each character’s RootPart.
Yes, this is a localscript.
Here is the code.
local TargetLocker = BillUI.Hit
TargetLocker.MouseEnter:Connect(function()
print("Lockon started for: "..char.Name)
end)
TargetLocker.MouseLeave:Connect(function()
print("Lockon cancelled for: "..char.Name)
end)
TargetLocker:GetPropertyChangedSignal("GuiState"):Connect(function()
if TargetLocker.GuiState == Enum.GuiState.Hover then
print("Lockon started for: "..char.Name)
elseif TargetLocker.GuiState == Enum.GuiState.Idle then
print("Lockon cancelled for: "..char.Name)
end
end)
TargetLocker.InputBegan:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.MouseMovement then
print("Mouse entered")
end
end)
TargetLocker.InputEnded:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.MouseMovement then
print("Mouse left")
end
end)
Here’s a video of it not working.
External MediaAs you can see, nothing is printed when I hover my mouse over the reticles.