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

Trying to make a selection gui to select stuff in workspace?

the example is like Miners Haven where you can select multiple parts i thought it was a gui and position and size according to the mouse but this doesn't work

local player = game.Players.LocalPlayer	
local mouse = player:GetMouse()
local gui = player.PlayerGui:WaitForChild("ScreenGui").Frame

mouse.Button1Down:Connect(function(down)
	
	local MouseCFrame = mouse.Hit.p	
		gui.Position =UDim2.new(MouseCFrame)
		
		mouse.Move:Connect(function()
		gui.Size =UDim2.new(mouse.Hit.p)		
		end)
end)

might be doing it wrong, i haven't scripted in a while.

1 answer

local selectionbox = Instance.new("SelectionBox")
selectionbox.Parent = game:GetService('Players').LocalPlayer.PlayerGui
local mouse = game.Players.LocalPlayer:GetMouse()


mouse.Move:Connect(function() --Detects Mouse Move
	local part = mouse.Target --Current mouse Target
	selectionbox.Adornee = mouse.Target --Changes selection box's Adornee to current Target
end) --end for {mouse.Move:Connect(function()}

There is an Instance called SelectionBox just use that.

3 comments

0

That only selects one part though. I'm trying to select multiple by dragging the mouse (while Mouse1Down is active) over them

0

Oh sorry,I hadn't readed your question correctly,I don't think i can make drag selection :(

0

No worries. Im just trying to get the gui to respond to the mouse. It's not going to the right position or changing size. That's why there's no selection in the script yet

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