Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How would I see if the mouse's target is a player's torso?

Asked by 8 years ago

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!

0
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. Perci1 4988 — 8y
0
Oh, then how would I see if the mouse is detecting the torso? script_ing 43 — 8y
0
I think he means specifically your torso UsernameEqualsTaken 30 — 8y

1 answer

Log in to vote
0
Answered by
cabbler 1942 Moderation Voter
8 years ago

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)
Ad

Answer this question