So Im trying to make a gui similar to the windows selection tool, one problem is that I can’t figure out a way to see what parts are overlapping or touching the gui. Here is my code:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local userinputservice = game:GetService(“UserInputService”)
local hold = false
local runservice = game:GetService(“RunService”)
local pastposition
local pastx
local pasty
–
player.CameraMaxZoomDistance = 50
userinputservice.InputBegan:connect(function(key,chat)
if chat == false and key.UserInputType == Enum.UserInputType.MouseButton1 then
pastposition = UDim2.new(0,mouse.X,0,mouse.Y)
script.Parent.Position = pastposition
pastx = mouse.X
pasty = mouse.Y
hold = true
end
end)
userinputservice.InputEnded:connect(function(key)
if key.UserInputType == Enum.UserInputType.MouseButton1 then
hold = false
end
end)
runservice.RenderStepped:connect(function()
if hold == true then
script.Parent.Visible = true
local newsize = UDim2.new(0,mouse.X+2,0,mouse.Y+2) - pastposition
script.Parent.Size = newsize
local children = workspace:GetChildren()
elseif hold == false then
script.Parent.Visible = false
end
end)