When I try this script in studio:
print(game.Players.LocalPlayer:GetMouse().Target.Name)
and my mouse is pointing at my torso, it prints Baseplate and won't detect my torso. Anyway to make it detect my torso and not the baseplate?
Thanks!
When I try this script in studio:
print(game.Players.LocalPlayer:GetMouse().Target.Name)
and my mouse is pointing at my torso, it prints Baseplate and won't detect my torso. Anyway to make it detect my torso and not the baseplate?
Thanks!
mouse events and even a ClickDetector can't detect your own torso, but it sure can detect other players' torsos. One thing you could do is weld a part to the torso and store it outside of the character, then check for it separately.
i.e.
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
repeat wait() until player.Character
local torso = player.Character:WaitForChild('Torso')
local t = torso:Clone()
t.Name = 'TorsoClone'
t.Transparency=1
t.CanCollide=false
local weld = Instance.new('Weld')
weld.Part0=torso
weld.Part1=t
weld.Parent=t
t.Parent=workspace
mouse.Button1Down:connect(function()
local target = mouse.Target
print(target.Name)
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
There's a few problems with your code and your logic, but funnily enough, that doesn't matter. mouse.Target won't detect your own character's Torso, or any of it for that matter.
Oh, then how would I see if the mouse is detecting the torso?
I think he means specifically your torso