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

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

Asked by 7 years ago

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

01local player = game.Players.LocalPlayer
02local mouse = player:GetMouse()
03local gui = player.PlayerGui:WaitForChild("ScreenGui").Frame
04 
05mouse.Button1Down:Connect(function(down)
06 
07    local MouseCFrame = mouse.Hit.p
08        gui.Position =UDim2.new(MouseCFrame)
09 
10        mouse.Move:Connect(function()
11        gui.Size =UDim2.new(mouse.Hit.p)       
12        end)
13end)

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

1 answer

Log in to vote
1
Answered by 7 years ago
1local selectionbox = Instance.new("SelectionBox")
2selectionbox.Parent = game:GetService('Players').LocalPlayer.PlayerGui
3local mouse = game.Players.LocalPlayer:GetMouse()
4 
5 
6mouse.Move:Connect(function() --Detects Mouse Move
7    local part = mouse.Target --Current mouse Target
8    selectionbox.Adornee = mouse.Target --Changes selection box's Adornee to current Target
9end) --end for {mouse.Move:Connect(function()}

There is an Instance called SelectionBox just use that.

0
That only selects one part though. I'm trying to select multiple by dragging the mouse (while Mouse1Down is active) over them RobloxianDestory 262 — 7y
0
Oh sorry,I hadn't readed your question correctly,I don't think i can make drag selection :( TheSkyofIndia 150 — 7y
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 RobloxianDestory 262 — 7y
Ad

Answer this question