So, what I want to do is once a block reaches a certain height, if a player places their mouse on it a selection box will appear. I also want a GUI to pop up for a brief amount of time. This is my script:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse() 
local selectionBox = Instance.new("SelectionBox")
local block = script.Parent
local selection = Instance.new("SelectionBox")
selection.Color3 = Color3.new(0.6,0.6,0,6)
selection.Parent = player.PlayerGui         
while wait() do
    if script.Parent.Size.Y >= 8 then
        local pgui = game.Players.LocalPlayer.PlayerGui
        local d = pgui.ScreenGui.Frame
        d.Visible = true
        wait(2)
        d.Visible = false
        mouse.Move:connect(function()
	        local Target = mouse.Target
	        if Target.Parent.Name == script.Parent.Name then
		        selection.Adornee = script.Parent
	end
	
	
end)
	    
		  
        
          
	end
        
end
   

Both are not working, and I clearly got stuck and could not finish the script. Any feedback would be appreciated.