Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I get a parts size by clicking it (using my mouse position)?

I've found this:

local TargetPart = game.Workspace:WaitForChild("Part")
local Mouse = game.Players.LocalPlayer:GetMouse()

Mouse.Button1Down:Connect(function()
    local Target = Mouse.Target
    if Target == TargetPart then
        print("Clicked!")
    end
end)

But I need to know the size of the part, without having to find the path of it. So like I could click on any random part and in the console, it would say the size.

NO CLICK DETECTORS ALSO

1 answer

✓ Accepted answer
local Player = game.Players.LocalPlayer -- Gets the player
local Mouse = Player:GetMouse() -- Gets the player mouse

Mouse.Button1Down:Connect(function()
	local Target = Mouse.Target --Gets the target where the player has clicked
	if Target then -- Check if target exist
		print(Target.Name, Target.Size) -- if target exist then it prints out the name and size (Remove Target.Name if you dont want it to print the name of the target.)
	end
end)

This should by right work, if not tell me the error and i will fix it. Have not tested it in studio.

This discussion is preserved as it was. New answers, comments, and votes are closed.