Hello. I found through ROBLOX many games where a selectionbox appeared around a character if you had the mouse on the character, and I now need to use that into my game. I made this script....
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local selection = Instance.new("SelectionBox")
selection.Color3 = Color3.fromRGB(255, 0, 0)
selection.Parent = script
mouse.Move:connect(function()
print ("MouseMoved!")
local target = mouse.Target
if not target then
selection.Adornee = nil
else
print ("Target is ".. target.Name)
if target.Parent:IsA("Model") then
print ("Model!")
local findhumanoid = target.Parent:FindFirstChild ("Humanoid")
if findhumanoid ~= nil then
print ("Humanoid!")
local findplayer = game.Players:FindFirstChild (findhumanoid.Parent.Name)
if findplayer ~= nil then
print ("player!")
script.SelectedPlayer = findplayer
selection.Parent = target.Parent
selection.Adornee = target.Parent
print ("DONE!")
end
end
end
end
end)
The script worked fine, with nothing in the output, but, when I held the mouse on a character, no selectionboxes appeared at all. I placed some prints, and I noticed that ROBLOX actually can't detect if the mouse is on a character because the mouse.Target can NOT detect Meshes! I wonder what should I do. What if I create a script that creates a square part on every character and the script, instead of detecting character's meshes, detects the part? Or maybe there is another way? Any help appreciated!

3 comments
Yeah, but it seems like It's not detecting the head. It's logical, It's amesh inside a part, but, anyway, any ideas of detecting the head?
(I will accept your answer anyway if you can't answer to that)
Is there a hat over the head? If there is, then that may be the problem. Otherwise, it should work.