The script below creates a "SelectionBox" around any part/model that the players mouse is targeting, it doesn't however create one around the Player Model, I believe this is because mouse.Target filters out the Player Model to prevent certain things. I'm wondering if theres anyway to go about this without having to use Raycasting as I haven't yet started learning about it.

Selectionbox Script

local modelMode = false

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local selection = Instance.new("SelectionBox")
selection.Color3 = Color3.new(0,0,5)
selection.Parent = player.PlayerGui

mouse.Move:Connect(function()
    local target = mouse.Target

    if not target then
        selection.Adornee = nil
    elseif modelMode then
        if target.Parent:IsA("Model") then
            selection.Adornee = target.Parent
        elseif target.Parent.Parent:IsA("Accoutrement") then
            selection.Adornee = target.Parent.Parent
        elseif target:IsA("BasePart") then
            selection.Adornee = target
        else
            selection.Adornee = nil
        end
    else
        if target:IsA("BasePart") then
            selection.Adornee = target
        else
            selection.Adornee = nil
        end
    end
end)

I'm not asking for anyone to script this for me, rather to let me know if there are any other ways to go about doing this.

EDIT: Here's a GIF of what I'm trying to explain https://gyazo.com/43a0c4181bf7ed19129e1691ef0110a2

EDIT EDIT: Learned some new info which may be useful in helping someone to help me. I've learned that mouse.Target doesn't filter out Character Models, rather it filters out the LocalPlayers Character Model. As seen below;

https://gyazo.com/c89f0de9390d065c5a760cd249894fde

2 comments

0

Can't you edit your original question instead of just writing "EDIT" on a new post?

0

But that doesn't get bumped.