I am a beginner developer and I want for tools in my building themed game to select parts just how it’s done in f3x tools, the particular problem I stumbled upon is making a GUI Selection Box - when you would hold shift and drag your mouse across the screen creating the area in which the parts are selected.
Going through hundreds of lines of code in f3x tools made me incredibly overwhelmed, so I ended up finding this post with the solution, however I do not completely understand how it works and therefore how to adjust it to my tools:
What do Slope1 and Slope2 particularly represent and what property of what instance should I assign them to, if that’s what they are meant for? How do I entangle the script to a Frame to make the selection area visible? Shouldn’t the Frame’s size constantly update while the Mouse is moving and how to achieve that?
Sorry if I asked too many questions!
I will be forever thankful for an explanation.
--In ReplicatedStorage insert a SeletionBox make the selection box properties to your needs
local SelectionBox = game:GetService("ReplicatedStorage").SelectionBox -- The location of your selection box
local Player = game.Players.LocalPlayer -- Gets the player locally.
local Mouse = Player:GetMouse() -- Gets the players mouse
-- Thats all the boring stuff done
Mouse.Move:Connect(function() -- function for when the mouse is moved
local target = workspace:FindPartOnRay(
Ray.new(Mouse.UnitRay.Origin,Mouse.UnitRay.Direction*50000)) -- Checks what part the mouse is currently on
if not target then
print("ok then")
else
if target:IsA("Part") then -- If the target is a part
SelectionBox:Clone().Parent = target -- Makes it so there is an outline around the part
else
local Check = target:FindFirstChild("SelectionBox") -- If the part has a selectionbox
if Check then -- Checks if it has it
target.SelectionBox:Destroy() -- Destroys it
end
end
end
end)
That should work please feel free to ask me if you don’t understand anything in this script.
Thanks for replies, that is something I have already been able to make for my selection, here is a little demo:
The only remaining feature of the selection that I am struggling with and which I meant by GUI Selection Box is like a Lasso tool, here is how it works in F3X: