Hi, I am making a game that relies on you clicking on parts, and hovering over them.
I have come to the issue that Mouse.Target doesn’t detect or just ignores my models.
The script I wrote:
local plr = game:GetService("Players").LocalPlayer
local mouse = plr:GetMouse()
local harvestgui = script.Parent.Harvest
mouse.Move:Connect(function()
if mouse.Target then
print(mouse.Target.Name)
if mouse.Target:HasTag("Harvestable") then
print("harvestable")
harvestgui.Visible = true
harvestgui.Position = UDim2.new(0,mouse.X + 10, 0,mouse.Y+ 10)
else
harvestgui.Visible = false
harvestgui.Position = UDim2.new(0,0,0,0)
end
end
end)
print(mouse.Target.Name)
^^ This for some reason, prints out the part UNDER my model.
If I make a part that is way smaller than my model, it still detects it. I also added a part that is the size of the entire model, into the model, and it still ignores it.
Mouse.Target doesn’t detect models but the parts inside the models. You could try checking the parent of the object that mouse.target returned if they are the model you are looking for.
if Mouse.Target:FindFirstAncestorWhichIsA("Model") then
end
No, the model is located on the baseplate. The script doesn’t detect ANY parts in the model, it just says ‘Baseplate’ when I hover my mouse over the model.
My camera is about 100 studs away, and the FOV is the regular, however, I think we are close to solving the problem, since I do manipulate the camera. Could it have something to do with CameraType?