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

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

Asked by 5 years ago

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

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
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.

Ad

Answer this question