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 6 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

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

Log in to vote
1
Answered by 6 years ago
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.

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 — 6y
0
Oh sorry,I hadn't readed your question correctly,I don't think i can make drag selection :( TheSkyofIndia 150 — 6y
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 — 6y
Ad

Answer this question